I made a map for a local game and seem to be stuck. The map is filtering features, but only from the current viewport. As the map I would like to use is only 6km square, I would like to query, not load the geojson in the webpage (10MB). queryrenderedfeatures and querysourcefeqtures only work in viewport geocoder doesn't search in self added items.
1 Answer
As per the Mapbox GL JS API docs, queryRenderedFeatures and querySourcesFeatures only guarantee to query features within the current viewport.
If you need to query outside this you could:
- Load the whole dataset as a GeoJSON (that's the option you mentioned)
- If you only have point data or only care about properties you could try the Mapbox tilequery API https://www.mapbox.com/api-documentation/#retrieve-features-from-vector-tiles but it only accepts a lng/lat not a bounding box.
- Build your own external API