Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get GPS location using Javascript without Internet [duplicate]

Hi Can we get GPS location using javascript without internet connection if device has GPS hardware?

Please note who are marking it as duplicate

I need javascript to work without internet connection and use GPS hardware to determine the location.

like image 202
vinod8812 Avatar asked Jun 26 '13 06:06

vinod8812


1 Answers

Javascript can show you geolocation via navigator.geolocation.

function getLocation()
{
    if (navigator.geolocation)
        navigator.geolocation.getCurrentPosition(showPosition);
    else
        console.log("Geolocation is not supported by this browser");
}
function showPosition(position)
{
    console.log("Latitude: " + position.coords.latitude);
    console.log("Longitude: " + position.coords.longitude); 
}
like image 194
uber5001 Avatar answered Oct 07 '22 23:10

uber5001