HTML and CSS Reference
In-Depth Information
The second grade of data inside the coordinates object is sup-
ported, but by default most (currently all) desktop browsers will
return null. However, if the device has something like a GPS on
board, the values can be determined, at which point the values
can be null, 0, or a floating point:
readonly attribute double altitude
readonly attribute double altitudeAccuracy
readonly attribute double heading
readonly attribute double speed
We'll look at how to use this second grade of data next.
Getting your hands on speed
More and more, we're seeing smartphones, tablets, and note-
books with onboard GPS. On these devices—depending on the
specific web browser and OS integration provided—the geolo-
cation API can provide a lot more information than just a one-off
set of coordinates (latitude, longitude, accuracy)—instead giving
access, through the second-order data, to speed, altitude, and
heading information as well.
In most cases, when you make a simple geolocation request,
you'll get only the latitude, longitude, and accuracy, and in most
cases this is enough for your application.
However, you can get your hands on the speed, altitude, and
heading through the geolocation API.
In most cases today, you'll need to tell the API to use highaccuracy
to enable the GPS device. Be aware that using the GPS will
quickly drain the device's battery, so make sure you're using the
technology because you need it, not just because you can.
In order to calculate the current speed, the device needs to
average the difference between a series of discrete location
measurements (or something to that effect?). For this reason,
you'll need to use geolocation.watchPosition and update the
current speed as it comes in:
 
Search WWH ::




Custom Search