Java Reference
In-Depth Information
•
position.speed
property returns the ground speed of the device in meters per
second
•
position.altitude
property returns an estimate of the device's altitude in
meters above the
WGS84
ellipsoid, which is a standard measurement for the cen-
ter of the Earth
•
position.heading
property returns the direction the device is moving in as a
bearing in degrees, measured clockwise from North
•
position.timestamp
property returns the time that the position information
was recorded
The
position
object also has properties that calculate the accuracy of the measurements.
These can be useful as sometimes you only need to know the town or city users are in,
while at other times you may need their exact position.
position.accuracy
property
returns the accuracy of the
latitude
and
longitude
properties in meters. The lower
the returned value the more accurate the measurements are, as is the case for the
pos-
ition.altitudeAccuracy
property, which returns the accuracy of the
altitude
property in meters.
In addition, the
geolocation
object has a
watchPosition()
method that will call a
callback function every time the position of the device is updated. This method returns an
ID that can be used to reference the position being watched:
if(navigator.geolocation) {
var id = navigator.geolocation.watchPosition(youAreHere);
}
The
clearWatch()
method can be used to stop the callback being called, using the ID
of the watch as an argument:
navigator.geolocation.clearWatch(id);
The Geolocation API provides a useful interface for adding location-based information to a
website or application. More information can be found at the
Mozilla Developer Network.
