Amit Gore
Amit Gore

Reputation: 451

Mapbox manipulating the layer features which are not in current view port

I am planning to change the source type from geojson to vector. I have created a source serving the vector tiles from my own server. My vector tiles have all the related application information I need.

I will be using this set up for a search platform where left side has the result and the other side has the corresponding map loaded with the tiles(one can interact with the map feature and its corresponding result card eg.highlighting the feature layer etc).

My application has couple of common scenarios like I can scroll the results down to load another batch of results but the problem is, how do I interact with the features which are not loaded in the current view port as mapbox calls its custom tiles as per z,x,y coordinate space which is unchanged in the scenario where user scrolls the result ?

Is there any way to trigger the call to the tile server and make the tiles available in the map for next batch of search result ?

Upvotes: 1

Views: 403

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126527

If your setup is that the source of truth is the vector dataset, and results are derived from that (probably using map.querySourceFeatures()) then you have a problem. There isn't an easy way to query source features that aren't in the current viewport. Probably you will need some of the data loaded by another means, such as a GeoJSON file (which I understand you just moved away from).

If you already have results obtained by a different means (a separate AJAX call), then you probably just need to manually pan the map to the location relevant to your results, using map.panTo().

I'm not sure I totally understood the scenario, though, or what exactly the problem is.

Upvotes: 1

Related Questions