Get Lattitude & Longitude from google Map

by Prabakaran 2013-04-04 14:45:03


<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyB6HHtXKJOnGVmQLm6cr5oXLFu-vJK8aSs" type="text/javascript"></script>
<script type="text/javascript">

function show_popup(){
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var center = new GLatLng(11.00, 78.00);
map.setCenter(center, 7);
geocoder = new GClientGeocoder();
var marker = new GMarker(center, {draggable: true});
map.addOverlay(marker);
document.getElementById("lat").value = center.lat().toFixed(5);
document.getElementById("lng").value = center.lng().toFixed(5);

GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("lat").value = point.lat().toFixed(5);
document.getElementById("lng").value = point.lng().toFixed(5);
});

GEvent.addListener(map, "moveend", function() {
map.clearOverlays();
var center = map.getCenter();
var marker = new GMarker(center, {draggable: true});
map.addOverlay(marker);
document.getElementById("lat").value = center.lat().toFixed(5);
document.getElementById("lng").value = center.lng().toFixed(5);

GEvent.addListener(marker, "dragend", function() {
var point =marker.getPoint();
map.panTo(point);
document.getElementById("lat").value = point.lat().toFixed(5);
document.getElementById("lng").value = point.lng().toFixed(5);
});
});
}
}
</script>
<div id="popup6" class="popup_block5"></div>
<div align="center" id="map" style="width: 500px; height: 400px"></div>
<table>
<tr>
<td><label>latitude<span>*</span></label></td>
<td><label>:</label></td>
<td><input type="text" name="latitude" id="lat" onclick="show_popup();" readonly value=""/>
<em></em>
</td>
</tr>
<tr>
<td><label>longitude<span>*</span></label></td>
<td><label>:</label></td>
<td><input type="text" name="longitude" id="lng" readonly value=""/>
<em></em>
</td>
</tr>
</table>


646
like
0
dislike
0
mail
flag

You must LOGIN to add comments