Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the URL for Google Map embedded on my website?

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?

like image 270
spig Avatar asked Dec 11 '09 19:12

spig


People also ask

How do I put a location map on my website?

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.


1 Answers

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.
   }
});
like image 157
Daniel Vassallo Avatar answered Sep 30 '22 14:09

Daniel Vassallo