Created
March 8, 2021 20:53
-
-
Save imanilchaudhari/867f1ea6b4f9970219df9e78467f09b1 to your computer and use it in GitHub Desktop.
Get Browsers Geolocation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.geolocation) { | |
navigator.geolocation.watchPosition (gotLocation, errLocation, {maximumAge: 30000}); | |
} | |
function gotLocation (position) { | |
var latitude = position.coords.latitude; | |
var longitude = position.coords.longitude; | |
var accuracy = position.coords.accuracy; | |
var timestamp = position.timestamp; | |
} | |
function errLocation (error) { | |
var errCode = error.code; | |
var errMess = error.message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment