[Answered ]-Find outermost cordinates from Geodjango queryset which has point column

2👍

Leaflet should be able to calculate the bounding box for the map based on the points that you wish to display on it. This can be done quite easily geodjango as well. extent is what you are looking for.

 bounds = Employee.objects.filter(some filter).extent()

This is deprecated in new version, instead use:

from django.contrib.gis.db.models import Extent
bounds = Employee.objects.filter(some filter).aggregate(Extent('point'))['point__extent']

In LefletJS:

var mymap = L.map('mapid').fitBounds(51.505, 51.507], [51.56, 50.98]], {padding: [10, 10]});
👤e4c5

Leave a comment