Given a GMarker JS variable, how do I obtain the HTML DOM element that represents it? I need this so I can insert a
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.