O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required