views:

243

answers:

3

I am displaying a map on a website using the Google Map API. I want to include a link on that same page to take them directly to the map on Google Maps.

Is there an API call I can make to the map to retrieve the URL of either the current location/zoom level or the starting location/zoom level?

+1  A: 

You don't need to use the API. From Google maps, click the Link link in the upper right corner, and copy the code for Paste HTML to embed in website and throw that in your page and it should be what you want. It puts in the link to see the larger map on Google maps. You can also click the Customize and preview embedded map link to see more options. It will display your map at whatever zoom and location you set it to.

Shawn Steward
I was hoping to have this dynamic. I currently have the lat/long so I am hoping to get the link, either by creating the link from lat/long or retrieving it from the map.
spig
+1  A: 

This should give you all the query parameters you could want: http://mapki.com/wiki/Google%5FMap%5FParameters

Then just make a link pointing at maps.google.com?<INSERT_PARAMS_HERE>

Zack
does Google have this specified anywhere?
spig
+1  A: 

This is the link to use to centre Google Maps to a point:

http://maps.google.com/?ll=LATITUDE,LONGITUDE&amp;z=ZOOM

All you need to do is to replace the above LATITUDE, LONGITUDE and ZOOM with the required coordinates.


To get the latitude and longitude where the mouse is clicked, you could use the following API code:

var map = new GMap2(document.getElementById("map_canvas"));

GEvent.addListener(map,"click", function(overlay, latlng) {     
   if (latlng) { 
      // latlng defines the latitude and longitude where the mouse was clicked.
   }
});
Daniel Vassallo
is there an API for this? so, will this change in the future or is it something they are set to support in the future? will I have code that magically breaks in the future if I code against this?
spig
It is the same format used when you click on the `LINK` button in Google Maps, so it should not change since people use these as permanent links.
Daniel Vassallo
Daniel Vassallo