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?
Go to maps.google.com. Type the location in the search box and click on Share. In the new window click on Embed a map and copy the HTML code of the map.
This is the link to use to centre Google Maps to a point:
http://maps.google.com/?ll=LATITUDE,LONGITUDE&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.
}
});
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