O'Reilly logo

jQuery Mobile Cookbook by Chetan K Jain

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

Tracking your location with the Geolocation API

The Geolocation API is a separate specification and is part of the HTML5 stack. You can use JavaScript and locate the client device location using various techniques, such as IP address, Wi-Fi, GSM/CDMA cell IDs, or device Global Positioning System (GPS). This recipe shows you how to find the current location using the Geolocation API in your app.

Getting ready

Copy the full code of this recipe from the code/11/geolocation folder. You can launch this code using the URL: http://localhost:8080/11/geolocation/main.html.

How to do it...

The steps to be followed are:

  1. Create main.html with an empty div tag to display the geolocation information.
    <div data-role='content'> <p>You current Position is ...</p> <div ...

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