O'Reilly logo

PhoneGap Mobile Application Development Cookbook by Matt Gifford

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

Obtaining device geolocation sensor information

Geolocation and the use of Global Positioning Satellites (GPS) allow developers to create dynamic real-time mapping, positioning, and tracking applications. Using the available geolocation methods we can retrieve a detailed set of information and properties to create location-aware applications. We can obtain the user's location if they are connected via the mobile data network or Wi-Fi.

How to do it...

We will use the geolocation functionality from the PhoneGap API to monitor the feedback from the device and obtain the relevant location information:

  1. Firstly, create the initial HTML layout and include the required script reference to the cordova-2.0.0.js file:
    <!DOCTYPE html> <html> <head> <meta name="viewport" ...

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