Get GPS Location Using Javascript Without Internet

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

Note who is marked as duplicate

I need javascript to work without an internet connection and use GPS equipment to determine location.

+4
source share
1 answer

Javascript can show you geolocation through 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); } 
+2
source

Source: https://habr.com/ru/post/1488212/


All Articles