Get Lat Long on google map

by admin on February 20th, 2012

You can get the latitude and longitude of any location on google map by just clicking on that location. Check this out:
But please make sure you have your own google api..

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″/>
<title>
Google Visualization API Sample
</title>
<!–<script type=”text/javascript” src=”http://www.google.com/jsapi”></script>–>
<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA_pv6r9wQUcY29kuVsKu_WRQNER5ay7E813Acg9jrQ4QegGSv

oxQtPvukQA-F6gkLXexTdocP127B3g” type=”text/javascript”></script>

<script type=”text/javascript”>

//<![CDATA[
var marca;
var latinput;
var loninput;
var mapleveli;
testing = function load() {
if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById(“map”));
//map.setCenter(new GLatLng(8.984868485653589, -79.51179027557373), 15);
map.setCenter(new GLatLng(37.4419, -122.1419), 15);
var point = new GLatLng(37.4419, -122.1419);

map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

latinput=document.getElementById(“latinput”);
loninput=document.getElementById(“loninput”);
mapleveli=document.getElementById(“maplevel”);

GEvent.addListener(map,”click”, function(overlay,point) {
//alert(point.x+” “+point.y);
//alert(point);
if(marca){
marca.hide();
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
else{
marca=new GMarker(point,{“clickable”:false});
map.addOverlay(marca);
latinput.value=point.y;
loninput.value=point.x;
mapleveli.value=map.getZoom()
}
});
}
}
window.onload=testing;
//]]>
</script>
</head>
<body style=”font-family: Arial;border: 0 none;”>

<label>Property Map Location</label>
<div id=”map” style=”width: 920px; height: 500px”>Loading…</div>

Latitude: <input name=”data[Property][latitude]” id=”latinput” value=”8.984868485653589″>
Longitude: <input name=”data[Property][longitude]” id=”loninput” value=”-79.51179027557373″>
Map level <input name=”data[Property][maplevel]” id=”maplevel” value=”15″>

</body>
</html>

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>