Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the DOM element associated with a Leaflet class

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

like image 204
hugo der hungrige Avatar asked Mar 09 '14 04:03

hugo der hungrige


2 Answers

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

like image 54
ericsoco Avatar answered Sep 29 '22 22:09

ericsoco


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.

like image 20
tmcw Avatar answered Sep 29 '22 22:09

tmcw