Enable location in browser and get current latitude and longitude

Now here the browser provides support for doing this Geolocation features.
I.E 9, Firefox, Chrome, Safari, and Opera support Geolocation.

<button onclick="EnableLocationGetLatLong()">Enable Location</button>
<p id="ShowLatLong"></p>
Add the above HTML  tag in your HTML page.
var x = document.getElementById("ShowLatLong");
function EnableLocationGetLatLong() {
if (navigator.geolocation) {
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
function GetLatLong(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
Add the above script tag in your script page.

0 Comment's

Comment Form