Teerath Kumar Teerath Kumar - 1 year ago 108
Javascript Question

Get gps location using javascript

I am using tablet, working on html application, want to get gps location without using any network connection.
please suggest me simple ways.

Answer Source

Using JS you can get it like this

 <script>
   var x = document.getElementById("demo");
    function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude +  "<br>Longitude: " + position.coords.longitude;
}
</script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download