if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( displayLocation, displayError); }
function displayLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude;
function displayError(error) { var errorTypes = { 0: "Unknown error", 1: "Permission denied", 2: "Position is not available", 3: "Request timeout" };
Geolocation |
getCurrentPosition watchPosition clearWatch |
getCurrentPosition(successHandler, errorhandler, positionOptions)
var positionOptions = { enableHighAccuracy: false, timeout: Infinity, maximumAge: 0}
Position |
coords timestamp |
Coordinates |
latitude longtitude accuracy altitude altitudeAccuracy heading speed |