HTML and CSS Reference
In-Depth Information
Figure 23-2:
A sample returned position.
Most of the details are in a
coords
subobject that contains at minimum the latitude, longitude, and accuracy
in meters. It might also contain additional data.
The full fields available in the position object follow:
•
Latitude:
The best guess latitude as a number
•
Longitude:
The best guess longitude as a number
•
Altitude:
An altitude estimate or null if there is no estimate
•
Accuracy:
The accuracy of latitude and longitude in meters
•
altitudeAccuracy:
The accuracy of the altitude in meters or null
•
heading:
If speed is greater than zero, the direction in degrees, otherwise
NaN
•
speed:
The speed in meters per second
As mentioned, only the longitude, latitude, and accuracy are guaranteed to be present.
getCurrentPosition
also accepts a third parameter that is an options object. The three options avail-
able as of this writing follow:
•
enableHighAccuracy:
Provides a hint that accuracy is important. This may require longer to gen-
erate a position and uses more battery, but the results will be more accurate if possible.
•
Timeout:
How long in milliseconds to wait for a position before timing out.
•
maximumAge:
The maximum age in milliseconds of the position. If greater than zero the method may
return a cached position.
By default
enableHighAccuracy
is set to false;
timeout
is set to 0, which means never to timeout;
and
maximumAge
is set to 0 as well, which means don't use cached data. If you want a position quickly, set
maximumAge
to a number greater than zero.