How can I get a drawn Object from a map leaflet draw using angular?

340 views Asked by At

I am using angular leaflet, leaflet-draw and I am trying to get a circle (or other drawn object) object to see if a point on the map appears within it overtime. I need to use it in a separate service. How can I access the data for an object already drawn somewhere else in my angular code?

1

There are 1 answers

0
jsNoob On BEST ANSWER

Found the answer. To access a drawn object in the way I was attempting, I had persisted the L.FeatureGroup object in my service. Inside this object is a layersDrawnItems sub-object. This object has a _layers array which contains the list of drawn objects.

They can then be accessed using the leaflet API. I still don't know how I was supposed to find this with the given documentation (unless I missed something completely obvious, which I am assuming I did, given that this would seem to be basic functionality) but if anyone else needs to know, here it is.