Sunday, September 6, 2009

Implement google map, how to get coordinates

Here are the very simple steps to implement google map in your application..

I assume you have a gmail account, and you have created your mark on

So first make your google location.

Now generate your key for google map, if you dont have click on following url to generate key

once you get your key, replace the key in following script.

< script src="" type="text/javascript" >< / script >
< script type="text/javascript" >

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("divMap"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

< / script >

Now place a div where you want to display the google map.

< div id="divMap" style="margin-top:12px;width:500px;height:400px;" >
< / div >

finally initialise the key

< script language="javascript" type="text/javascript" >
window.load= initialize();
< / script >

Google ma getting dipalyed on your site, but you might be wondering why your location not gettting displayed. For that you need to change the coorodinates.

How to get the coordinates ? Simply open your location in google map and copy paste the following javascript code on browser. youe get your location, replace the code in map.setCenter(new GLatLng(37.4419, -122.1419), 13); method in above script.



click on the right top "send" you get the following code

Hi, I'd like to share a Google Maps link with you.
Link: <,72.861425&spn=0.007281,0.009624&z=17 >

Enjoy google map in your application.


No comments:

ETG Consultancy

Web Designing Development Analysis & Promotion
Asp.Net 2.0 SQL WWF WCF SEO Marketing Ajax JQuery NHibernate MVC