Get Current Google Map
How do I get the current Google Map that is alrea开发者_StackOverflow社区dy initialized on the page with the Javascript V3 api, so I can reset a marker?
declare the map object in javascript as global then you get the anywhere in javascript
If you have a marker and you want to reference the map that it relates to you can simply call getMap()
on the marker.
var myMap = myMarker.getMap();
When called from an object it returns the map on which the object is rendered/displayed. This is true for most objects in the google.maps namespace (Marker, Polyline, Rectangle, etc).
If you take a look through the reference page you can see which objects getMap()
is an available method for.
精彩评论