Getting geographical location input

One of the exciting new features in HTML5 is the geolocation API (http://www.w3.org/TR/geolocation-API/). It allows the developer to ask for the user's location. This API allows the developer to get geographic coordinates, such as latitude and longitude.

Before this API developers had to rely on more crude methods, such as GeoIP databases. These methods produced results that had poor accuracy. Depending on the user's browser, device, and the availability of GPS on it, the geolocation API could give results with a few meters accuracy.

In this recipe, we're going to display the user's location on a map. To do this, we're going to use the Leaflet library. The use of this library to show maps is covered in the Displaying ...

Get HTML5 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.