Accessing Map from other buttons

17 views
Skip to first unread message

Bradken Webmaster

unread,
Feb 9, 2012, 7:21:01 PM2/9/12
to google-map...@googlegroups.com
Could someone help point  me in the right direction.  I've tried googling an answer and still can't find anything.
 
I have 4 or 5 buttons/links just on my webpage that needs to zoom the map in to a marker and display a pop up and I just can't work out how to do it.
 
I have a number of markers which when clicked bring up a popup and I can have them interact with the rest of the website, I just can't get the rest of the site to interact with the map.
 
Any help would be appreciated.

Thank you
Regards
Byron

Barry Hunter

unread,
Feb 9, 2012, 7:30:13 PM2/9/12
to google-map...@googlegroups.com
At the most basic level, make sure you store the created 'Map' object
in a global variable - then your other functions can do things with
it....


var map ;

function initialize() {
....
map = new google.maps.Map(document.getElementById("map_canvas"),
....
}

function recentermap() {
map.setCenter(new google.maps.LatLng(-34.397, 150.644));
}

recentermap can then be called from whereever - your real function
will do something more exciting tho!


... if still stuck suggest posting a link to your map, so can give
more specific advice.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/QB0vJ2g1WwUJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Bradken Webmaster

unread,
Feb 9, 2012, 7:59:12 PM2/9/12
to google-map...@googlegroups.com
You my good sir are a campion.  That is exactly the starting point I needed.

Thank you so much.
Reply all
Reply to author
Forward
0 new messages