Chapter 8

Geolocation

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • Understanding geolocation
  • Using the Position, PositionError, and Coordinates objects
  • Using Geolocation methods
  • Using Geolocation options and arguments

In Chapter 7, you learned how to use the compass. In this chapter, you learn how to use the device’s built-in geolocation services.

GETTING TO KNOW GEOLOCATION

In this section, you learn what geolocation is, and how you can use it.

What Is Geolocation?

Simply put, geolocation involves the identification of a real-world geographic location of a device — in this case, the smartphone you have with you. The most common way to determine a device’s geolocation is to use an internal GPS feature to determine latitude and longitude.

However, some devices might use other services to infer a location — for example, an IP address, Radio Frequency Identification (RFID), WiFi Media Access Control (MAC) addresses, or cell tower triangulation. Because of the wide divergence of methods used to obtain geolocation coordinates, no one can guarantee that the PhoneGap API will return a device’s actual location.

Using Geolocation

The most obvious reason to use geolocation is the recent trend to indicate where something happened. For example, geolocation data is being added to photos (so you can better organize them on Flickr photo galleries by geographic location, for example), and social location services like Gowalla and Foursquare allow you to “check in” to a location. Some existing applications ...

Get Beginning PhoneGap 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.