dan
dan

Reputation: 2957

How do you get all features within a bounding box regardless of zoom?

Given a bound box like the below picture, how do you get all the features contained within, regardless of if they are visible or not.

enter image description here

I have tried to get all roads using

 let features = map.querySourceFeatures('composite', {sourceLayer: 'road'})

But it only gives me roads that are visible if I am zoomed in.

I have also tried

let features = map.queryRenderedFeatures([tile_info.swPt, tile_info.nePt])

But again, it only gets features visible on the map based on zoom level.

I need all the features within the bounding box regardless of what you can see or zoom level

Upvotes: 0

Views: 884

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126767

It is in the nature of vector tiles that you can not do what you want to do here. You can only query data which has been loaded into the browser, and the point of the vector tile architecture is to prevent that happening at lower zooms.

You could consider a server based approach like Tilequery.

Upvotes: 2

Related Questions