Tutorial by Examples

if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationFailure); } else { console.log("Geolocation is not supported by this browser."); } // Function that will be called if the query succeeds var geolocationSuccess = function(pos) {...
In the event that geolocation fails, your callback function will receive a PositionError object. The object will include an attribute named code that will have a value of 1, 2, or 3. Each of these numbers signifies a different kind of error; the getErrorCode() function below takes the PositionError....
You can also receive regular updates of the user's location; for example, as they move around while using a mobile device. Location tracking over time can be very sensitive, so be sure to explain to the user ahead of time why you're requesting this permission and how you'll use the data. if (naviga...

Page 1 of 1