Given a GMarker JS variable, how do I obtain the HTML DOM element that represents it? I need this so I can insert a <div>
of my own into the map with the correct z-index.
Thanks.
Sorry to post on such an old question, but I've just come across this myself. The solution I used in Google Maps APIv3 was to copy the "Custom Marker" from the Google Maps samples and add a simple method getDOMElement
, which returns the div
generated in the Marker's construction.
CustomMarker.prototype.getDOMElement = function() {
return this.div_;
}
You can then use marker.getDOMElement().style
to dynamically change the styling of your marker, and the img
child element of marker.getDOMElement()
is the icon used, so you can change that dynamically too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With