6

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.

vinod8812
  • 645
  • 10
  • 27
  • Are you using https://developer.mozilla.org/en-US/docs/WebAPI/Using_geolocation ? I've never really used it, especially offline, so I'm not sure how it works in different situations – Ian Jun 26 '13 at 06:19
  • http://stackoverflow.com/questions/2577305/how-to-get-gps-location-from-the-web-browser – Ved Jun 26 '13 at 06:19
  • 2
    please note I want GPS location without internet connection using GPS hardware... – vinod8812 Jun 26 '13 at 06:56

1 Answers1

2

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); 
}
uber5001
  • 3,864
  • 4
  • 23
  • 44