I’m creating a geo app with Google Maps and I receive bounding box as 2 coordinates:
- north east
- south west
I have a model with PointField.
from django.contrib.gis.db import models
class Place(models.Model):
name = models.CharField(max_length=200)
address = models.CharField(max_length=200)
location = models.PointField()
How could I perform a query to get all places within bounding box?
Assuming that the “2 coordinates” are x,y tuples, for example:
You can extract the coordinates and create a bounding box tuple:
Using the bounding box geometry, query your Place records using a spatial lookup: