Geolocation

The geolocation object provides access to the device's GPS sensor.

Geolocation provides location information for the device, such as latitude and longitude. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs. No guarantee is given that the API returns the device's actual location.

This API is based on the W3C Geolocation API Specification. Some devices (Android, BlackBerry, Bada, Windows Phone 7, webOS and Tizen, to be specific) already provide an implementation of this spec. For those devices, the built-in support is used instead of replacing it with Cordova's implementation. For devices that don't have geolocation support, the Cordova implementation adheres to the W3C specification.

Important privacy note: Collection and use of geolocation data raises important privacy issues. Your app's privacy policy should discuss how the app uses geolocation data, whether it is shared with any other parties, and the level of precision of the data (for example, coarse, fine, ZIP code level, etc.). Geolocation data is generally considered sensitive because it can reveal a person's whereabouts and, if stored, the history of his or her travels. Therefore, in addition to your app's privacy policy, you should strongly consider providing a just-in-time notice prior to your app accessing geolocation data (if the device operating system doesn't do so already). That notice should provide the same information noted above, as well as obtaining the user's permission (e.g., by presenting choices for "OK" and "No Thanks"). For more information, please see the Privacy Guide.

Methods

Arguments

Objects (Read-Only)

Permissions

Android

app/res/xml/config.xml

<plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />

app/AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

Bada

No permissions are required.

BlackBerry WebWorks

www/plugins.xml

<plugin name="Geolocation" value="org.apache.cordova.geolocation.Geolocation" />

www/config.xml

<rim:permissions>
    <rim:permit>read_geolocation</rim:permit>
</rim:permissions>

iOS

config.xml

<plugin name="Geolocation" value="CDVLocation" />

webOS

No permissions are required.

Windows Phone

Properties/WPAppManifest.xml

<Capabilities>
    <Capability Name="ID_CAP_LOCATION" />
</Capabilities>

Reference: Application Manifest for Windows Phone

Tizen

No permissions are required.