I have an existing map on a page. I can select that element using something along the lines of document.getElementById() to get the HTMLElement javascript object. Is it possible to get the instance of google.maps.Map created when the map is initialised, i.e. is it a property of the HTMLElement object or in its prototype?
Share
You can’t get
google.maps.Mapobject fromDOM Element,on which Google Maps object have been constructed.google.maps.Mapis just a wrapper, which controlsDOM Elementfor viewing the map, and that element does not have reference to its wrapper.If your problem is only the scope, make
mapas a property ofwindowobject, and it will be accessible from everywhere in your page. You can make'map'as global by using one of these:or