0

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 1

2

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:

  1. Load the whole dataset as a GeoJSON (that's the option you mentioned)
  2. 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.
  3. Build your own external API

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.