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?
To download your data, head to Google Maps on your computer and sign in. Next, click the three-line menu icon in the top-left corner next to the Search box. Near the bottom, select “Your Data in Maps.” On the next screen, scroll down to and select “Download Your Maps Data.”
The API is available for developers that have a free Google Maps API key. Usage of the API is not strictly free, but they do offer $200 of free monthly usage for most users. The pricing scales to fit your particular needs and you are only charged for your API usage.
Click Share or embed map. Click Embed map. Copy the text in the box. Paste it into the HTML of your website or blog.
You can't get google.maps.Map
object from DOM Element
,on which Google Maps object have been constructed. google.maps.Map
is just a wrapper, which controls DOM Element
for viewing the map, and that element does not have reference to its wrapper.
If your problem is only the scope, make map
as a property of window
object, and it will be accessible from everywhere in your page. You can make 'map'
as global by using one of these:
window.map = new google.maps.Map(..)
or
map = new google.maps.Map(...) //AVOID 'var'
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