Here we will see How to get Latitude and longitude based on
address in Asp.Net.
HTML CODE:
<div>
<textarea id="txtAddress" rows="3" cols="25"></textarea>
<br />
<input type="button" onclick="GetLocation()" value="Get Location" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyA-Dvf0kFAG9y2vRvkhbRy-obcU_wtSh3U&sensor=false"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function
GetLocation() {
var
geocoder = new google.maps.Geocoder();
var
address = document.getElementById("txtAddress").value;
geocoder.geocode({ 'address': address }, function
(results, status) {
if
(status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert("Latitude: " + latitude + "\nLongitude: " + longitude);
} else
{
alert("Request failed.")
}
});
};
</script>
1 comments:
commentskalo sebalik nya bagaimana tanpa KEY
ReplyThanks for comments.....