2

I found out that sanity supports Geopoint type, but I could not find any information if it's possible to do any filter operation on this type. Are geospatial queries possible?

1 Answers1

1

Simpler syntax for geospatial queries is on the roadmap.

If you for instance want to make a Lat/Lng bounded query, you can do that the following way, given the schema:

export default {
   name: 'aDocumentType',
   type: 'document',
   fields: [
    {
       name: 'position',
       type: 'geopoint'
    }
   ]
}

Let's say we have used Mapbox, and have a LngLatBounds object. Now we can make a query, using the params that maps to this object:

*[
  _type == "aDocumentType &&
  position.lng < $bounds._ne.lng &&
  position.lat < $bounds._ne.lat &&
  position.lng > $bounds._sw.lng &&
  position.lat > $bounds._sw.lat &&
]
knut
  • 371
  • 1
  • 6