Get the current geolocation

A basic code snippet to get the current location of the user
var options = {
    enableHighAccuracy : true,
    maximumAge : 0,
    timeout : 50000
};

function successCallback(geoPosition) {
    alert(JSON.stringify(geoPosition));
}

function errorCallback(error) {
    alert(error.message);
}
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);

Responses

0 Replies