cordova-plugin-geolocation
Advanced tools
Comparing version 2.4.3 to 3.0.0
{ | ||
"name": "cordova-plugin-geolocation", | ||
"version": "2.4.3", | ||
"version": "3.0.0", | ||
"description": "Cordova Geolocation Plugin", | ||
@@ -24,2 +24,5 @@ "cordova": { | ||
}, | ||
"bugs": { | ||
"url": "https://issues.apache.org/jira/browse/CB" | ||
}, | ||
"keywords": [ | ||
@@ -41,4 +44,4 @@ "cordova", | ||
"scripts": { | ||
"test": "npm run jshint", | ||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" | ||
"test": "npm run eslint", | ||
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests" | ||
}, | ||
@@ -50,2 +53,5 @@ "author": "Apache Software Foundation", | ||
"3.0.0": { | ||
"cordova-android": ">=6.3.0" | ||
}, | ||
"4.0.0": { | ||
"cordova": ">100" | ||
@@ -56,4 +62,10 @@ } | ||
"devDependencies": { | ||
"jshint": "^2.6.0" | ||
"eslint": "^4.0.0", | ||
"eslint-config-semistandard": "^11.0.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-node": "^5.0.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1" | ||
} | ||
} |
@@ -24,5 +24,5 @@ --- | ||
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| | ||
|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | ||
|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)| | ||
|AppVeyor|Travis CI| | ||
|:-:|:-:| | ||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-geolocation?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-geolocation)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)| | ||
@@ -165,11 +165,16 @@ # cordova-plugin-geolocation | ||
Since iOS 10 it's mandatory to add a `NSLocationWhenInUseUsageDescription` entry in the info.plist. | ||
Since iOS 10 it's mandatory to provide an usage description in the `info.plist` if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description. | ||
This plugins requires the following usage description: | ||
* `NSLocationWhenInUseUsageDescription` describes the reason that the app accesses the user's location. | ||
To add this entry into the `info.plist`, you can use the `edit-config` tag in the `config.xml` like this: | ||
``` | ||
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge"> | ||
<string>need location access to find things nearby</string> | ||
</edit-config> | ||
``` | ||
`NSLocationWhenInUseUsageDescription` describes the reason that the app accesses the user's location. When the system prompts the user to allow access, this string is displayed as part of the dialog box. To add this entry you can pass the variable `GEOLOCATION_USAGE_DESCRIPTION` on plugin install. | ||
Example: | ||
`cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="your usage message"` | ||
If you don't pass the variable, the plugin will add an empty string as value. | ||
### Android Quirks | ||
@@ -176,0 +181,0 @@ |
@@ -23,2 +23,11 @@ <!-- | ||
### 3.0.0 (Nov 06, 2017) | ||
* [CB-13267](https://issues.apache.org/jira/browse/CB-13267) (iOS): Remove **iOS** usage descriptions | ||
* [CB-13516](https://issues.apache.org/jira/browse/CB-13516) (all): Add 'protective' entry to `cordovaDependencies` | ||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again | ||
* [CB-13294](https://issues.apache.org/jira/browse/CB-13294) Remove `cordova-plugin-compat` | ||
* [CB-13299](https://issues.apache.org/jira/browse/CB-13299) (CI) Fix **Android** builds | ||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint` | ||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`. | ||
### 2.4.3 (Apr 27, 2017) | ||
@@ -25,0 +34,0 @@ * [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README` |
@@ -21,3 +21,3 @@ /* | ||
*/ | ||
// latest geolocation spec can be found here: http://www.w3.org/TR/geolocation-API/ | ||
@@ -28,7 +28,7 @@ | ||
module.exports = { | ||
getLocation: function(success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
function successCallback(position) { | ||
// Cordova is creating Position object using just coords | ||
success(position.coords); | ||
getLocation: function (success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
function successCallback (position) { | ||
// Cordova is creating Position object using just coords | ||
success(position.coords); | ||
} | ||
@@ -41,7 +41,7 @@ geo.getCurrentPosition(successCallback, error, { | ||
addWatch: function(success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
addWatch: function (success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
var id = args[0]; | ||
function successCallback(position) { | ||
success(position.coords); | ||
function successCallback (position) { | ||
success(position.coords); | ||
} | ||
@@ -55,7 +55,7 @@ var nativeId = geo.watchPosition(successCallback, error, { | ||
clearWatch: function(success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
clearWatch: function (success, error, args) { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
var id = args[0]; | ||
if(id in idsMap) { | ||
if (id in idsMap) { | ||
geo.clearWatch(idsMap[id]); | ||
@@ -65,3 +65,3 @@ delete idsMap[id]; | ||
if(success) { | ||
if (success) { | ||
success(); | ||
@@ -72,2 +72,2 @@ } | ||
require("cordova/exec/proxy").add("Geolocation", module.exports); | ||
require('cordova/exec/proxy').add('Geolocation', module.exports); |
@@ -19,5 +19,5 @@ /* | ||
var PositionError = require('./PositionError'); | ||
var callbacks = {}; | ||
var locs = {}; | ||
var PositionError = require('./PositionError'); | ||
var callbacks = {}; | ||
var locs = {}; | ||
@@ -27,3 +27,3 @@ // constants | ||
function ensureAndCreateLocator() { | ||
function ensureAndCreateLocator () { | ||
var deferral; | ||
@@ -51,26 +51,28 @@ | ||
function createErrorCode(loc) { | ||
function createErrorCode (loc) { | ||
/* eslint-disable no-fallthrough */ | ||
switch (loc.locationStatus) { | ||
case Windows.Devices.Geolocation.PositionStatus.initializing: | ||
// This status indicates that a location device is still initializing | ||
case Windows.Devices.Geolocation.PositionStatus.noData: | ||
// No location data is currently available | ||
case Windows.Devices.Geolocation.PositionStatus.notInitialized: | ||
// This status indicates that the app has not yet requested | ||
// location data by calling GetGeolocationAsync() or | ||
// registering an event handler for the positionChanged event. | ||
case Windows.Devices.Geolocation.PositionStatus.notAvailable: | ||
// Location is not available on this version of Windows | ||
return PositionError.POSITION_UNAVAILABLE; | ||
case Windows.Devices.Geolocation.PositionStatus.initializing: | ||
// This status indicates that a location device is still initializing | ||
case Windows.Devices.Geolocation.PositionStatus.noData: | ||
// No location data is currently available | ||
case Windows.Devices.Geolocation.PositionStatus.notInitialized: | ||
// This status indicates that the app has not yet requested | ||
// location data by calling GetGeolocationAsync() or | ||
// registering an event handler for the positionChanged event. | ||
case Windows.Devices.Geolocation.PositionStatus.notAvailable: | ||
// Location is not available on this version of Windows | ||
return PositionError.POSITION_UNAVAILABLE; | ||
case Windows.Devices.Geolocation.PositionStatus.disabled: | ||
// The app doesn't have permission to access location, | ||
// either because location has been turned off. | ||
return PositionError.PERMISSION_DENIED; | ||
case Windows.Devices.Geolocation.PositionStatus.disabled: | ||
// The app doesn't have permission to access location, | ||
// either because location has been turned off. | ||
return PositionError.PERMISSION_DENIED; | ||
default: | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
function createResult(pos) { | ||
/* eslint-enable no-fallthrough */ | ||
function createResult (pos) { | ||
var res = { | ||
@@ -101,4 +103,4 @@ accuracy: pos.coordinate.accuracy, | ||
if (loc) { | ||
var highAccuracy = args[0], | ||
maxAge = args[1]; | ||
var highAccuracy = args[0]; | ||
var maxAge = args[1]; | ||
@@ -109,3 +111,3 @@ loc.desiredAccuracy = highAccuracy ? | ||
loc.reportInterval = maxAge ? maxAge : 0; | ||
loc.reportInterval = maxAge || 0; | ||
@@ -123,7 +125,6 @@ loc.getGeopositionAsync().then( | ||
); | ||
} | ||
else { | ||
} else { | ||
fail({ | ||
code: PositionError.POSITION_UNAVAILABLE, | ||
message: "You do not have the required location services present on your system." | ||
message: 'You do not have the required location services present on your system.' | ||
}); | ||
@@ -145,21 +146,21 @@ } | ||
switch (e.status) { | ||
case Windows.Devices.Geolocation.PositionStatus.noData: | ||
case Windows.Devices.Geolocation.PositionStatus.notAvailable: | ||
fail({ | ||
code: PositionError.POSITION_UNAVAILABLE, | ||
message: "Data from location services is currently unavailable or you do not have the required location services present on your system." | ||
}); | ||
break; | ||
case Windows.Devices.Geolocation.PositionStatus.noData: | ||
case Windows.Devices.Geolocation.PositionStatus.notAvailable: | ||
fail({ | ||
code: PositionError.POSITION_UNAVAILABLE, | ||
message: 'Data from location services is currently unavailable or you do not have the required location services present on your system.' | ||
}); | ||
break; | ||
case Windows.Devices.Geolocation.PositionStatus.disabled: | ||
fail({ | ||
code: PositionError.PERMISSION_DENIED, | ||
message: "Your location is currently turned off." | ||
}); | ||
break; | ||
case Windows.Devices.Geolocation.PositionStatus.disabled: | ||
fail({ | ||
code: PositionError.PERMISSION_DENIED, | ||
message: 'Your location is currently turned off.' | ||
}); | ||
break; | ||
// case Windows.Devices.Geolocation.PositionStatus.initializing: | ||
// case Windows.Devices.Geolocation.PositionStatus.ready: | ||
default: | ||
break; | ||
default: | ||
break; | ||
} | ||
@@ -169,6 +170,6 @@ }; | ||
loc.desiredAccuracy = highAccuracy ? | ||
Windows.Devices.Geolocation.PositionAccuracy.high : | ||
Windows.Devices.Geolocation.PositionAccuracy.default; | ||
Windows.Devices.Geolocation.PositionAccuracy.high : | ||
Windows.Devices.Geolocation.PositionAccuracy.default; | ||
if (cordova.platformId == 'windows') { | ||
if (cordova.platformId === 'windows') { // eslint-disable-line no-undef | ||
// 'positionchanged' event fails with error below if movementThreshold is not set | ||
@@ -185,4 +186,4 @@ // JavaScript runtime error: Operation aborted | ||
loc.addEventListener("positionchanged", onPositionChanged); | ||
loc.addEventListener("statuschanged", onStatusChanged); | ||
loc.addEventListener('positionchanged', onPositionChanged); | ||
loc.addEventListener('statuschanged', onStatusChanged); | ||
@@ -197,7 +198,7 @@ callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged }; | ||
var callback = callbacks[clientId]; | ||
var loc = locs[clientId]; | ||
var loc = locs[clientId]; | ||
if (callback && loc) { | ||
loc.removeEventListener("positionchanged", callback.pos); | ||
loc.removeEventListener("statuschanged", callback.status); | ||
loc.removeEventListener('positionchanged', callback.pos); | ||
loc.removeEventListener('statuschanged', callback.status); | ||
@@ -212,2 +213,2 @@ delete callbacks[clientId]; | ||
require("cordova/exec/proxy").add("Geolocation", module.exports); | ||
require('cordova/exec/proxy').add('Geolocation', module.exports); |
@@ -22,3 +22,3 @@ /* | ||
/* jshint jasmine: true */ | ||
/* eslint-env jasmine */ | ||
/* global WinJS, device */ | ||
@@ -46,3 +46,3 @@ | ||
}; | ||
var succeed = function (done, context) { | ||
@@ -65,3 +65,3 @@ // prevents done() to be called several times | ||
// On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run | ||
var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone); | ||
var isWindowsStore = (cordova.platformId === 'windows8') || (cordova.platformId === 'windows' && !WinJS.Utilities.isPhone); // eslint-disable-line no-undef | ||
var majorDeviceVersion = null; | ||
@@ -74,25 +74,24 @@ var versionRegex = /(\d)\..+/.exec(device.version); | ||
// Also, Android emulator doesn't provide geo fix without manual interactions or mocks | ||
var skipAndroid = cordova.platformId == "android" && (device.isVirtual || majorDeviceVersion >= 6); | ||
var skipAndroid = cordova.platformId === 'android' && (device.isVirtual || majorDeviceVersion >= 6); // eslint-disable-line no-undef | ||
var isIOSSim = false; // if iOS simulator does not have a location set, it will fail. | ||
describe('Geolocation (navigator.geolocation)', function () { | ||
it("geolocation.spec.1 should exist", function () { | ||
it('geolocation.spec.1 should exist', function () { | ||
expect(navigator.geolocation).toBeDefined(); | ||
}); | ||
it("geolocation.spec.2 should contain a getCurrentPosition function", function () { | ||
it('geolocation.spec.2 should contain a getCurrentPosition function', function () { | ||
expect(typeof navigator.geolocation.getCurrentPosition).toBeDefined(); | ||
expect(typeof navigator.geolocation.getCurrentPosition == 'function').toBe(true); | ||
expect(typeof navigator.geolocation.getCurrentPosition === 'function').toBe(true); | ||
}); | ||
it("geolocation.spec.3 should contain a watchPosition function", function () { | ||
it('geolocation.spec.3 should contain a watchPosition function', function () { | ||
expect(typeof navigator.geolocation.watchPosition).toBeDefined(); | ||
expect(typeof navigator.geolocation.watchPosition == 'function').toBe(true); | ||
expect(typeof navigator.geolocation.watchPosition === 'function').toBe(true); | ||
}); | ||
it("geolocation.spec.4 should contain a clearWatch function", function () { | ||
it('geolocation.spec.4 should contain a clearWatch function', function () { | ||
expect(typeof navigator.geolocation.clearWatch).toBeDefined(); | ||
expect(typeof navigator.geolocation.clearWatch == 'function').toBe(true); | ||
expect(typeof navigator.geolocation.clearWatch === 'function').toBe(true); | ||
}); | ||
@@ -106,3 +105,3 @@ | ||
it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { | ||
it('geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number', function (done) { | ||
if (isWindowsStore || skipAndroid) { | ||
@@ -121,3 +120,3 @@ pending(); | ||
it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) { | ||
it('geolocation.spec.9 on failure should return PositionError object with error code constants', function (done) { | ||
if (isWindowsStore || skipAndroid) { | ||
@@ -129,3 +128,3 @@ pending(); | ||
fail.bind(this, done), | ||
function(gpsError) { | ||
function (gpsError) { | ||
// W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface | ||
@@ -147,3 +146,3 @@ expect(gpsError.PERMISSION_DENIED).toBe(1); | ||
it("geolocation.spec.6 should be called with a Position object", function (done) { | ||
it('geolocation.spec.6 should be called with a Position object', function (done) { | ||
if (isWindowsStore || skipAndroid) { | ||
@@ -157,10 +156,9 @@ pending(); | ||
done(); | ||
}, function(err){ | ||
if(err.message && err.message.indexOf('kCLErrorDomain') > -1){ | ||
console.log("Error: Location not set in simulator, tests will fail."); | ||
}, function (err) { | ||
if (err.message && err.message.indexOf('kCLErrorDomain') > -1) { | ||
console.log('Error: Location not set in simulator, tests will fail.'); | ||
expect(true).toBe(true); | ||
isIOSSim = true; | ||
done(); | ||
} | ||
else { | ||
} else { | ||
fail(done); | ||
@@ -179,6 +177,6 @@ } | ||
beforeEach(function(done) { | ||
beforeEach(function (done) { | ||
// This timeout is set to lessen the load on platform's geolocation services | ||
// which were causing occasional test failures | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
done(); | ||
@@ -195,3 +193,3 @@ }, 100); | ||
it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { | ||
it('geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number', function (done) { | ||
if (isWindowsStore || skipAndroid) { | ||
@@ -211,3 +209,3 @@ pending(); | ||
it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) { | ||
it('geolocation.spec.10 on failure should return PositionError object with error code constants', function (done) { | ||
if (isWindowsStore || skipAndroid) { | ||
@@ -220,3 +218,3 @@ pending(); | ||
fail.bind(this, done, context, 'Unexpected win'), | ||
function(gpsError) { | ||
function (gpsError) { | ||
if (context.done) return; | ||
@@ -247,3 +245,3 @@ context.done = true; | ||
it("geolocation.spec.8 should be called with a Position object", function (done) { | ||
it('geolocation.spec.8 should be called with a Position object', function (done) { | ||
if (isWindowsStore || skipAndroid || isIOSSim) { | ||
@@ -262,3 +260,3 @@ pending(); | ||
expect(p.timestamp).toBeDefined(); | ||
// callback could be called sync so we invoke done async to make sure we know watcher id to .clear in afterEach | ||
// callback could be called sync so we invoke done async to make sure we know watcher id to .clear in afterEach | ||
setTimeout(function () { | ||
@@ -291,6 +289,6 @@ done(); | ||
*/ | ||
function setLocationStatus(status) { | ||
function setLocationStatus (status) { | ||
document.getElementById('location_status').innerHTML = status; | ||
} | ||
function setLocationDetails(p) { | ||
function setLocationDetails (p) { | ||
var date = (new Date(p.timestamp)); | ||
@@ -304,3 +302,3 @@ document.getElementById('latitude').innerHTML = p.coords.latitude; | ||
document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; | ||
document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); | ||
document.getElementById('timestamp').innerHTML = date.toDateString() + ' ' + date.toTimeString(); | ||
} | ||
@@ -311,9 +309,9 @@ | ||
*/ | ||
function stopLocation() { | ||
function stopLocation () { | ||
var geo = navigator.geolocation; | ||
if (!geo) { | ||
alert('navigator.geolocation object is missing.'); | ||
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef | ||
return; | ||
} | ||
setLocationStatus("Stopped"); | ||
setLocationStatus('Stopped'); | ||
if (watchLocationId) { | ||
@@ -331,3 +329,3 @@ geo.clearWatch(watchLocationId); | ||
if (!geo) { | ||
alert('navigator.geolocation object is missing.'); | ||
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef | ||
return; | ||
@@ -343,3 +341,3 @@ } | ||
var fail = function (e) { | ||
console.log("watchLocation fail callback with error code " + e); | ||
console.log('watchLocation fail callback with error code ' + e); | ||
stopLocation(geo); | ||
@@ -350,3 +348,3 @@ }; | ||
watchLocationId = geo.watchPosition(success, fail, { enableHighAccuracy: true }); | ||
setLocationStatus("Running"); | ||
setLocationStatus('Running'); | ||
}; | ||
@@ -360,3 +358,3 @@ | ||
if (!geo) { | ||
alert('navigator.geolocation object is missing.'); | ||
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef | ||
return; | ||
@@ -371,3 +369,3 @@ } | ||
setLocationDetails(p); | ||
setLocationStatus("Done"); | ||
setLocationStatus('Done'); | ||
}; | ||
@@ -377,7 +375,7 @@ | ||
var fail = function (e) { | ||
console.log("getLocation fail callback with error code " + e.code); | ||
setLocationStatus("Error: " + e.code); | ||
console.log('getLocation fail callback with error code ' + e.code); | ||
setLocationStatus('Error: ' + e.code); | ||
}; | ||
setLocationStatus("Retrieving location..."); | ||
setLocationStatus('Retrieving location...'); | ||
@@ -393,14 +391,14 @@ // Get location | ||
'<b>Status:</b> <span id="location_status">Stopped</span>' + | ||
'<table width="100%">', | ||
latitude = '<tr>' + | ||
'<table width="100%">'; | ||
var latitude = '<tr>' + | ||
'<td><b>Latitude:</b></td>' + | ||
'<td id="latitude"> </td>' + | ||
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' + | ||
'</tr>', | ||
longitude = '<tr>' + | ||
'</tr>'; | ||
var longitude = '<tr>' + | ||
'<td><b>Longitude:</b></td>' + | ||
'<td id="longitude"> </td>' + | ||
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' + | ||
'</tr>', | ||
altitude = '<tr>' + | ||
'</tr>'; | ||
var altitude = '<tr>' + | ||
'<td><b>Altitude:</b></td>' + | ||
@@ -410,9 +408,9 @@ '<td id="altitude"> </td>' + | ||
'(meters) height above the [<a href="http://dev.w3.org/geo/api/spec-source.html#ref-wgs">WGS84</a>] ellipsoid. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude">#ref]</a></td>' + | ||
'</tr>', | ||
accuracy = '<tr>' + | ||
'</tr>'; | ||
var accuracy = '<tr>' + | ||
'<td><b>Accuracy:</b></td>' + | ||
'<td id="accuracy"> </td>' + | ||
'<td>(meters; non-negative; 95% confidence level) the accuracy level of the latitude and longitude coordinates. [<a href="http://dev.w3.org/geo/api/spec-source.html#accuracy">#ref]</a></td>' + | ||
'</tr>', | ||
heading = '<tr>' + | ||
'</tr>'; | ||
var heading = '<tr>' + | ||
'<td><b>Heading:</b></td>' + | ||
@@ -423,4 +421,4 @@ '<td id="heading"> </td>' + | ||
'(degrees; 0° ≤ heading < 360°) direction of travel of the hosting device- counting clockwise relative to the true north. [<a href="http://dev.w3.org/geo/api/spec-source.html#heading">#ref]</a></td>' + | ||
'</tr>', | ||
speed = '<tr>' + | ||
'</tr>'; | ||
var speed = '<tr>' + | ||
'<td><b>Speed:</b></td>' + | ||
@@ -430,9 +428,9 @@ '<td id="speed"> </td>' + | ||
'(meters per second; non-negative) magnitude of the horizontal component of the hosting device current velocity. [<a href="http://dev.w3.org/geo/api/spec-source.html#speed">#ref]</a></td>' + | ||
'</tr>', | ||
altitude_accuracy = '<tr>' + | ||
'</tr>'; | ||
var altitude_accuracy = '<tr>' + | ||
'<td><b>Altitude Accuracy:</b></td>' + | ||
'<td id="altitude_accuracy"> </td>' + | ||
'<td>null if not supported;<br>(meters; non-negative; 95% confidence level) the accuracy level of the altitude. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude-accuracy">#ref]</a></td>' + | ||
'</tr>', | ||
time = '<tr>' + | ||
'</tr>'; | ||
var time = '<tr>' + | ||
'<td><b>Time:</b></td>' + | ||
@@ -443,4 +441,4 @@ '<td id="timestamp"> </td>' + | ||
'</table>' + | ||
'</div>', | ||
actions = | ||
'</div>'; | ||
var actions = | ||
'<div id="cordova-getLocation"></div>' + | ||
@@ -453,6 +451,6 @@ 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' + | ||
'<p/> <div id="cordova-getOld"></div>' + | ||
'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.', | ||
values_info = | ||
'<h3>Details about each value are listed below in the status box</h3>', | ||
note = | ||
'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.'; | ||
var values_info = | ||
'<h3>Details about each value are listed below in the status box</h3>'; | ||
var note = | ||
'<h3>Allow use of current location, if prompted</h3>'; | ||
@@ -459,0 +457,0 @@ |
@@ -22,3 +22,3 @@ /* | ||
var exec = cordova.require('cordova/exec'); | ||
var exec = cordova.require('cordova/exec'); // eslint-disable-line no-undef | ||
var utils = require('cordova/utils'); | ||
@@ -32,24 +32,24 @@ var PositionError = require('./PositionError'); | ||
module.exports = { | ||
getCurrentPosition: function(success, error, args) { | ||
var win = function() { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
geo.getCurrentPosition(success, error, args); | ||
getCurrentPosition: function (success, error, args) { | ||
var win = function () { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
geo.getCurrentPosition(success, error, args); | ||
}; | ||
var fail = function() { | ||
var fail = function () { | ||
if (error) { | ||
error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access')); | ||
error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access')); | ||
} | ||
}; | ||
exec(win, fail, "Geolocation", "getPermission", []); | ||
exec(win, fail, 'Geolocation', 'getPermission', []); | ||
}, | ||
watchPosition: function(success, error, args) { | ||
watchPosition: function (success, error, args) { | ||
var pluginWatchId = utils.createUUID(); | ||
var win = function() { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
var win = function () { | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args); | ||
}; | ||
var fail = function() { | ||
var fail = function () { | ||
if (error) { | ||
@@ -59,3 +59,3 @@ error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access')); | ||
}; | ||
exec(win, fail, "Geolocation", "getPermission", []); | ||
exec(win, fail, 'Geolocation', 'getPermission', []); | ||
@@ -65,11 +65,11 @@ return pluginWatchId; | ||
clearWatch: function(pluginWatchId) { | ||
var win = function() { | ||
clearWatch: function (pluginWatchId) { | ||
var win = function () { | ||
var nativeWatchId = pluginToNativeWatchMap[pluginWatchId]; | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
geo.clearWatch(nativeWatchId); | ||
}; | ||
exec(win, null, "Geolocation", "getPermission", []); | ||
exec(win, null, 'Geolocation', 'getPermission', []); | ||
} | ||
}; |
@@ -22,8 +22,8 @@ /* | ||
var idsMap = {}, | ||
geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); | ||
var idsMap = {}; | ||
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); // eslint-disable-line no-undef | ||
module.exports = { | ||
getLocation: function(success, error, args) { | ||
getLocation: function (success, error, args) { | ||
var successCallback = function (result) { | ||
@@ -42,24 +42,24 @@ var pos = result.coords; | ||
addWatch: function(success, error, args) { | ||
var id = args[0], | ||
successCallback = function (result) { | ||
var pos = result.coords; | ||
pos.timestamp = result.timestamp; | ||
if (success) { | ||
success(pos); | ||
} | ||
}, | ||
nativeId = geo.watchPosition(successCallback, error, { | ||
enableHighAccuracy: args[1] | ||
}); | ||
addWatch: function (success, error, args) { | ||
var id = args[0]; | ||
var successCallback = function (result) { | ||
var pos = result.coords; | ||
pos.timestamp = result.timestamp; | ||
if (success) { | ||
success(pos); | ||
} | ||
}; | ||
var nativeId = geo.watchPosition(successCallback, error, { | ||
enableHighAccuracy: args[1] | ||
}); | ||
idsMap[id] = nativeId; | ||
}, | ||
clearWatch: function(success, error, args) { | ||
clearWatch: function (success, error, args) { | ||
var id = args[0]; | ||
if(id in idsMap) { | ||
if (id in idsMap) { | ||
geo.clearWatch(idsMap[id]); | ||
delete idsMap[id]; | ||
} | ||
if(success) { | ||
if (success) { | ||
success(); | ||
@@ -71,2 +71,2 @@ } | ||
require("cordova/exec/proxy").add("Geolocation", module.exports); | ||
require('cordova/exec/proxy').add('Geolocation', module.exports); |
@@ -33,3 +33,3 @@ /* | ||
*/ | ||
var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) { | ||
var Coordinates = function (lat, lng, alt, acc, head, vel, altacc) { | ||
/** | ||
@@ -36,0 +36,0 @@ * The latitude of the position. |
@@ -22,12 +22,12 @@ /* | ||
var argscheck = require('cordova/argscheck'), | ||
utils = require('cordova/utils'), | ||
exec = require('cordova/exec'), | ||
PositionError = require('./PositionError'), | ||
Position = require('./Position'); | ||
var argscheck = require('cordova/argscheck'); | ||
var utils = require('cordova/utils'); | ||
var exec = require('cordova/exec'); | ||
var PositionError = require('./PositionError'); | ||
var Position = require('./Position'); | ||
var timers = {}; // list of timers in use | ||
var timers = {}; // list of timers in use | ||
// Returns default params, overrides if provided with values | ||
function parseParameters(options) { | ||
function parseParameters (options) { | ||
var opt = { | ||
@@ -59,9 +59,9 @@ maximumAge: 0, | ||
// Returns a timeout failure, closed over a specified timeout value and error callback. | ||
function createTimeout(errorCallback, timeout) { | ||
var t = setTimeout(function() { | ||
function createTimeout (errorCallback, timeout) { | ||
var t = setTimeout(function () { | ||
clearTimeout(t); | ||
t = null; | ||
errorCallback({ | ||
code:PositionError.TIMEOUT, | ||
message:"Position retrieval timed out." | ||
code: PositionError.TIMEOUT, | ||
message: 'Position retrieval timed out.' | ||
}); | ||
@@ -73,3 +73,3 @@ }, timeout); | ||
var geolocation = { | ||
lastPosition:null, // reference to last known (cached) position returned | ||
lastPosition: null, // reference to last known (cached) position returned | ||
/** | ||
@@ -82,3 +82,3 @@ * Asynchronously acquires the current position. | ||
*/ | ||
getCurrentPosition:function(successCallback, errorCallback, options) { | ||
getCurrentPosition: function (successCallback, errorCallback, options) { | ||
argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments); | ||
@@ -89,5 +89,5 @@ options = parseParameters(options); | ||
// before the "timeout" param provided expires | ||
var timeoutTimer = {timer:null}; | ||
var timeoutTimer = {timer: null}; | ||
var win = function(p) { | ||
var win = function (p) { | ||
clearTimeout(timeoutTimer.timer); | ||
@@ -102,9 +102,9 @@ if (!(timeoutTimer.timer)) { | ||
{ | ||
latitude:p.latitude, | ||
longitude:p.longitude, | ||
altitude:p.altitude, | ||
accuracy:p.accuracy, | ||
heading:p.heading, | ||
velocity:p.velocity, | ||
altitudeAccuracy:p.altitudeAccuracy | ||
latitude: p.latitude, | ||
longitude: p.longitude, | ||
altitude: p.altitude, | ||
accuracy: p.accuracy, | ||
heading: p.heading, | ||
velocity: p.velocity, | ||
altitudeAccuracy: p.altitudeAccuracy | ||
}, | ||
@@ -116,3 +116,3 @@ p.timestamp | ||
}; | ||
var fail = function(e) { | ||
var fail = function (e) { | ||
clearTimeout(timeoutTimer.timer); | ||
@@ -133,4 +133,4 @@ timeoutTimer.timer = null; | ||
fail({ | ||
code:PositionError.TIMEOUT, | ||
message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter." | ||
code: PositionError.TIMEOUT, | ||
message: "timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter." | ||
}); | ||
@@ -150,3 +150,3 @@ // Otherwise we have to call into native to retrieve a position. | ||
} | ||
exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]); | ||
exec(win, fail, 'Geolocation', 'getLocation', [options.enableHighAccuracy, options.maximumAge]); | ||
} | ||
@@ -164,3 +164,3 @@ return timeoutTimer; | ||
*/ | ||
watchPosition:function(successCallback, errorCallback, options) { | ||
watchPosition: function (successCallback, errorCallback, options) { | ||
argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments); | ||
@@ -174,3 +174,3 @@ options = parseParameters(options); | ||
var fail = function(e) { | ||
var fail = function (e) { | ||
clearTimeout(timers[id].timer); | ||
@@ -183,3 +183,3 @@ var err = new PositionError(e.code, e.message); | ||
var win = function(p) { | ||
var win = function (p) { | ||
clearTimeout(timers[id].timer); | ||
@@ -191,9 +191,9 @@ if (options.timeout !== Infinity) { | ||
{ | ||
latitude:p.latitude, | ||
longitude:p.longitude, | ||
altitude:p.altitude, | ||
accuracy:p.accuracy, | ||
heading:p.heading, | ||
velocity:p.velocity, | ||
altitudeAccuracy:p.altitudeAccuracy | ||
latitude: p.latitude, | ||
longitude: p.longitude, | ||
altitude: p.altitude, | ||
accuracy: p.accuracy, | ||
heading: p.heading, | ||
velocity: p.velocity, | ||
altitudeAccuracy: p.altitudeAccuracy | ||
}, | ||
@@ -206,3 +206,3 @@ p.timestamp | ||
exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]); | ||
exec(win, fail, 'Geolocation', 'addWatch', [id, options.enableHighAccuracy]); | ||
@@ -216,7 +216,7 @@ return id; | ||
*/ | ||
clearWatch:function(id) { | ||
clearWatch: function (id) { | ||
if (id && timers[id] !== undefined) { | ||
clearTimeout(timers[id].timer); | ||
timers[id].timer = false; | ||
exec(null, null, "Geolocation", "clearWatch", [id]); | ||
exec(null, null, 'Geolocation', 'clearWatch', [id]); | ||
} | ||
@@ -223,0 +223,0 @@ } |
@@ -24,3 +24,3 @@ /* | ||
var Position = function(coords, timestamp) { | ||
var Position = function (coords, timestamp) { | ||
if (coords) { | ||
@@ -27,0 +27,0 @@ this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy); |
@@ -29,3 +29,3 @@ /* | ||
*/ | ||
var PositionError = function(code, message) { | ||
var PositionError = function (code, message) { | ||
this.code = code || null; | ||
@@ -32,0 +32,0 @@ this.message = message || ''; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
346303
46
0
775
0
7