Google Maps API Tutorial© 2006, 2007, 2008, 2009 Mike Williams
|Translate this page:|
ParametersPassing and receiving parameters isn't part of the API itself, but it's something that you might want to do with your map.
Receiving ParametersYou can add parameters to the end of a URL like this example_linktothis.htm?lat=53.816134&lng=-3.055567&zoom=18&type=k
Using parameters allows you to use the same page to display different information. In this case I'm using the parameters to pass the latitude, longitude, zoom and map type, but you could pass other information in the same way.
In the example I perform the following steps:
The example uses .toLowerCase() to convert the received string to lower case.
MarkersYou can use the same mechanism to specify a marker, and have the page centre on that marker or open its info window, like this example_linktomarker.htm?marker=1 or like this example_linktomarker.htm?id=Marker%20Two
If passing an id string that may contain spaces or other punctuation, use unescape() to convert the escaped characters back into normal text.
Sending ParametersThe first example page has a "Link to this page" link.
That link points to a URL that contains parameters that contain the lat, lng, zoom and type settings for the current display.
In order for such right-clicks to work, it's not possible to generate the URL on demand. What we have to do is create the URL every time the map state changes, so that it's already there when someone right-clicks it.
In my example, I perform the following steps: