Marker Visibility Control
It would be nice to be able to control the visibility of a marker (hide/show) at either the marker or the layer level. I currently do this in both Google Map API and Openlayer Map API to allow the user to filter between different types of markers on the map.
Technically, doing removeLayer and addLayer for hiding/showing markers has the same performance as hiding them with display = ‘none’, as addLayer only initializes the marker once and only appends it to the DOM on subsequent calls. So I don’t see much need to add such methods for individual markers.
However this would be a very useful feature for LayerGroup’s, where I could implement putting all layers from the same group into a div container to be able to hide them all at once for a considerable performance gain. This is definitely in the plans.
In case I just want to rename marker(change its title), I also had to remove and recreate marker using map.removeLayer<marker>)....
Bradford McCarron commented
I was just wondering if you were able to move all of the layers into a single div container? This would make thousands of markers disappear in an instant! Please let me know if this is possible or when it might be possible. You're the man. Thank you.
A Chang commented
Hey, I found the latest version support this via map.addLayer(<marker>), and map.removeLayer<marker>), I didn't realize that a single marker counts as layer, but in this case anything that supports the ILayer interface can be added/removed in this way. I was previously using LayerGroups to hide/show different types of layers. Nicely you can control visibility with both types pretty much at the same time.