HTML and CSS Reference
In-Depth Information
CHAPTER 7
Geolocation
The Geolocation API provides scripted access to geographical location information
associated with the hosting device. This gives your applications the ability to locate users
and track their latitude and longitude as they move about. This functionality could be
used for many interesting use cases such as:
Geofencing
Give your app the ability to schedule a task to alert users the moment they enter or
leave a location. You could also target ads for users within a certain city or state.
Geocoding
Combine your app with a service like the Google Maps API ( Figure 7-1 ), and you
can translate latitude and longitude coordinates into actual postal addresses.
General tracking
Track distances driven, walked, or ran.
The API itself is device agnostic; it doesn't care how the browser determines location.
The underlying mechanism to obtain the user's actual location may be through WiFi,
GPS, or by the user actually entering a zip code into the device. The API is designed to
gather both “one-shot” position requests and repeated position updates. Of course, Ge‐
olocation is no different than any of the other HTML5e APIs in regard to bugs, work‐
arounds, and differences in implementations across browsers. After a review of the ba‐
sics, we'll dive into the cross-browser nuances.
 
Search WWH ::




Custom Search