ubergesundheit/Leaflet.EdgeMarker

Find and EdgeMarker on a Map

lisaWriteJava opened this issue · 9 comments

Hello,

We've incorporated the EdgeMarker plugin to be added to the map. My question find the EdgeMarkers on a map and then perform an action such as destroy()?

You have to assign the edgemarker to a variable and the call destroy on it

So edgemarkers are defined and map.addTo(definedEdgemarker) is added to the map. I'm not quite sure how if I'm in another block of code, and get a handle to the map which contains the _borderMakerLayer, would I be able to call the destroy when the map doesn't have the actual edgeMarker class.

you could set a custom property to the layer which you will then check for existence.

Since I know that the edgemarkers are there, by checking for the _borderMakerLayer, I'm trying to figure out how I'd remove it from the map not having an actual edgeMarker class.

Whats wrong with the solution from here? #13 (comment)

There's no handle to the edgeMarker from the map. If I were able to get a handle to the edgeMarker, I could call the destroy.

Then use my solution with the custom property on the layer. You could even save a reference to the edgemarker to the layer.
Iterate all layers with http://leafletjs.com/reference-1.0.3.html#map-eachlayer
Check for the reference and call destroy on it

thanks, I'll give it a try.

Thanks for your help I found a different way to solve the problem. I just added a listener to events. I then listened for the events in the codes that already has the edgemarker and the map and was able to add and remove the edgemarkers from there. I'm closing the issue.