<span id='addressObj'> </span>
<script type='text/javascript'>
var geocoder = new google.maps.Geocoder();
var myLatlng = new google.maps.LatLng(00.0000, 00.0000); // put proper lat lon value
var address;
geocoder.geocode({'latLng': myLatlng}, function(results, status) { // getting address from latLong i.e latitude and longitude
if (status == google.maps.GeocoderStatus.OK) { // If status is OK means address is found by server
if (results[1]){
address = results[1].formatted_address;
document.getElementById('addressObj').innerHTML = address;
} else {
document.getElementById('addressObj').innerHTML = status;
}
} else { // Otherwise it return address empty or undefined thats why we display status and latLong only
document.getElementById('addressObj').innerHTML = status;
}
});
</script>
0 comments:
Post a Comment