O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

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

Working with geolocation

With the arrival of HTML5, one of the many new APIs and concepts introduced in the specification is the possibility to identify the location of the client that is loading the web page, through the Geolocation API (http://dev.w3.org/geo/api/spec-source.html). Of course, in the world of web mapping applications, this opens new and great possibilities.

In this recipe, we are going to show how easily we can identify the current location of the user and center the map's viewport to it:

Working with geolocation

Every time the user clicks on the Geolocation button, the map's viewport will be moved to the current user's location and a marker will be placed ...

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