-
Hey! I am looking to get a list of all the Markers I have added to the map, which are in view. I have been trying to use map.queryRenderedFeatures(), but I cannot figure out where to put "my-layer-name" from the example
I currently have a GeoJson, with the id as "my-layer-name"
but the query returns an empty list: If I remove the feature option query Any idea on how I can get the Markers I have added, which are in a bounding box/in view? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yeah this is a bit tricky. In my email notifications I saw you wrote something about using querySourceFeatures, but maybe deleted it. Did that not work for you? The MarkerLayer code actually uses that same function internally to manage the list of visible markers. The trick is that Markers live in the HTML DOM rather than being part of the WebGL side, so the Can you go into more detail about what you're actually seeing and what the query functions are returning when you call them? Specifically around this sentence:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. Your suggestion on the bounding box has worked perfectly. Thanks! |
Beta Was this translation helpful? Give feedback.
BTW if you don't have too many markers, it might also work for you to just put a
move
ormoveend
event handler on the map and then read the map's bounding box in there and create a filtered list of where the bounding box overlaps with your GeoJSON.