This plugin provides information about the device’s location, 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. There is no guarantee that the API returns the device’s actual location.
This API is based on the W3C Geolocation API Specification, and only executes on devices that don’t already provide an implementation.
WARNING: 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 user’s whereabouts and, if stored, the history of their travels. Therefore, in addition to the app’s privacy policy, you should strongly consider providing a just-in-time notice before the app accesses 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
navigator.geolocation.getCurrentPosition navigator.geolocation.watchPosition navigator.geolocation.clearWatch Objects (Read-Only) Position PositionError Coordinates
Quick Example
watchLoc = function() {
navigator.geolocation.getCurrentPosition(onLocSuccess, onLocFail);
};
//will handle map position here
onLocSuccess = function(position) {
alert(“Latitude: ”+position.coords.latitude+”Longtitude: ”+ position.coords.longitude);
};
onLocFail = function(error) {
alert(‘code: ‘ + error.code + ‘\n’ +
‘message: ‘ + error.message + ‘\n’);
};
Source Documentation:
http://plugins.cordova.io/#/package/org.apache.cordova.geolocation