Introduction:
Here I will explain how to get latitude and longitude from address Google map api using JavaScript in website or Google maps autocomplete address textbox to get latitude and longitude without map example. By using google.maps.places.Autocomplete class we can implement Google places autocomplete textbox and display selected address latitude and longitude details.
To implement places or address autocomplete textbox using Google maps Google API we need to write the code like as shown below
Here I will explain how to get latitude and longitude from address Google map api using JavaScript in website or Google maps autocomplete address textbox to get latitude and longitude without map example. By using google.maps.places.Autocomplete class we can implement Google places autocomplete textbox and display selected address latitude and longitude details.
To implement places or address autocomplete textbox using Google maps Google API we need to write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps Api Get
Current Location Latitude and Longitude</title>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script type="text/javascript">
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function
(position) {
var geolocation = new google.maps.LatLng(
position.coords.latitude, position.coords.longitude);
var location = "Latitude: " +
geolocation.A + "
";
";
location += "Longitude:
" + geolocation.F;
document.getElementById('lblResult').innerHTML
= location
});
}
}
</script>
</head>
<body>
<div style="margin-top:200px; margin-left:200px">
<span>Location:</span>
<input type="button"
id="btnGet"
value="Get
Latitude & Longitude" onclick="geolocate()" /><br /><br />
Current Location Latitude & Longitude:<br /><br />
<label id="lblResult"
/>
</div>
</body>
</html>
No comments:
Post a Comment