Get the DOM element associated with a Leaflet class

8k views Asked by At

Is there a way to get the corresponding DOM element of a Marker or Layer with Leaflet, like it is with Google Maps?

2

There are 2 answers

1
tmcw On BEST ANSWER

You can use the internal ._container property on most Leaflet objects, like layers and markers. Note that it's internal for a reason - if you use Canvas mode or Leaflet decides to change its internal API, your code will break.

1
ericsoco On

getContainer() is a more formal way to get at the DOM element, but is only available on the Map, TileLayer, and Controls classes.