New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-geolocation

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-geolocation - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

.jshintrc

11

package.json
{
"name": "cordova-plugin-geolocation",
"version": "2.1.0",
"version": "2.2.0",
"description": "Cordova Geolocation Plugin",

@@ -39,4 +39,11 @@ "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"
},
"author": "Apache Software Foundation",
"license": "Apache 2.0"
"license": "Apache-2.0",
"devDependencies": {
"jshint": "^2.6.0"
}
}

5

README.md

@@ -20,2 +20,4 @@ <!--

[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)
# cordova-plugin-geolocation

@@ -47,3 +49,3 @@

choices for __OK__ and __No Thanks__). For more information, please
see the Privacy Guide.
see the [Privacy Guide](http://cordova.apache.org/docs/en/latest/guide/appdev/privacy/index.html).

@@ -84,3 +86,2 @@ This plugin defines a global `navigator.geolocation` object (for platforms

- Windows Phone 7 and 8
- Windows 8
- Windows

@@ -87,0 +88,0 @@

@@ -23,2 +23,9 @@ <!--

### 2.2.0 (Apr 15, 2016)
* Replace `PermissionHelper.java` with `cordova-plugin-compat`
* CB-10691 Check the context to avoid null errors
* CB-10636 Add `JSHint` for plugins
* Using a fallback epsilon in case `Number.EPSILON` is not defined.
* CB-10574 MobileSpec can't get results for **WP8.1** Builds
### 2.1.0 (Jan 15, 2016)

@@ -25,0 +32,0 @@ * CB-10319 **Android** Adding reflective helper methods for permission requests

@@ -17,29 +17,30 @@ /*

var PositionError = require('./PositionError'),
ids = {},
loc;
/* global Windows, WinJS */
function ensureLocator() {
var PositionError = require('./PositionError');
var callbacks = {};
var locs = {};
// constants
var FALLBACK_EPSILON = 0.001;
function ensureAndCreateLocator() {
var deferral;
if (!loc) {
loc = new Windows.Devices.Geolocation.Geolocator();
var loc = new Windows.Devices.Geolocation.Geolocator();
if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') {
deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) {
if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) {
return loc;
}
if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') {
deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) {
if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) {
return loc;
}
return WinJS.Promise.wrapError({
code: PositionError.PERMISSION_DENIED,
message: 'Geolocation access has not been allowed by user.'
});
return WinJS.Promise.wrapError({
code: PositionError.PERMISSION_DENIED,
message: 'Geolocation access has not been allowed by user.'
});
} else {
deferral = WinJS.Promise.wrap(loc);
}
});
} else {
deferral = WinJS.Promise.wrap(loc);
}
}

@@ -49,3 +50,3 @@ return deferral;

function createErrorCode() {
function createErrorCode(loc) {
switch (loc.locationStatus) {

@@ -55,7 +56,7 @@ case Windows.Devices.Geolocation.PositionStatus.initializing:

case Windows.Devices.Geolocation.PositionStatus.noData:
// No location data is currently available
// 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.
// location data by calling GetGeolocationAsync() or
// registering an event handler for the positionChanged event.
case Windows.Devices.Geolocation.PositionStatus.notAvailable:

@@ -82,3 +83,3 @@ // Location is not available on this version of Windows

};
if (pos.coordinate.point) {

@@ -93,3 +94,3 @@ res.latitude = pos.coordinate.point.position.latitude;

}
return res;

@@ -100,3 +101,3 @@ }

getLocation: function (success, fail, args, env) {
ensureLocator().done(function () {
ensureAndCreateLocator().done(function (loc) {
if (loc) {

@@ -118,3 +119,3 @@ var highAccuracy = args[0],

fail({
code: createErrorCode(),
code: createErrorCode(loc),
message: err.message

@@ -135,11 +136,11 @@ });

addWatch: function (success, fail, args, env) {
ensureLocator().done(function () {
var clientId = args[0],
highAccuracy = args[1],
ensureAndCreateLocator().done(function (loc) {
var clientId = args[0];
var highAccuracy = args[1];
onPositionChanged = function (e) {
var onPositionChanged = function (e) {
success(createResult(e.position), { keepCallback: true });
},
};
onStatusChanged = function (e) {
var onStatusChanged = function (e) {
switch (e.status) {

@@ -177,3 +178,7 @@ case Windows.Devices.Geolocation.PositionStatus.noData:

// WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers
loc.movementThreshold = Number.EPSILON;
if (Number.EPSILON) {
loc.movementThreshold = Number.EPSILON;
} else {
loc.movementThreshold = FALLBACK_EPSILON;
}
}

@@ -184,15 +189,18 @@

ids[clientId] = { pos: onPositionChanged, status: onStatusChanged };
}, fail);
callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged };
locs[clientId] = loc;
}, fail);
},
clearWatch: function (success, fail, args, env) {
var clientId = args[0],
callbacks = ids[clientId];
var clientId = args[0];
var callback = callbacks[clientId];
var loc = locs[clientId];
if (callbacks) {
loc.removeEventListener("positionchanged", callbacks.pos);
loc.removeEventListener("statuschanged", callbacks.status);
if (callback && loc) {
loc.removeEventListener("positionchanged", callback.pos);
loc.removeEventListener("statuschanged", callback.status);
delete ids[clientId];
delete callbacks[clientId];
delete locs[clientId];
}

@@ -204,2 +212,2 @@

require("cordova/exec/proxy").add("Geolocation", module.exports);
require("cordova/exec/proxy").add("Geolocation", module.exports);

@@ -21,2 +21,6 @@ /*

*/
/* jshint jasmine: true */
/* global WinJS, device */
exports.defineAutoTests = function () {

@@ -271,2 +275,36 @@ var fail = function (done, context, message) {

/**
* Set location status
*/
function setLocationStatus(status) {
document.getElementById('location_status').innerHTML = status;
}
function setLocationDetails(p) {
var date = (new Date(p.timestamp));
document.getElementById('latitude').innerHTML = p.coords.latitude;
document.getElementById('longitude').innerHTML = p.coords.longitude;
document.getElementById('altitude').innerHTML = p.coords.altitude;
document.getElementById('accuracy').innerHTML = p.coords.accuracy;
document.getElementById('heading').innerHTML = p.coords.heading;
document.getElementById('speed').innerHTML = p.coords.speed;
document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
}
/**
* Stop watching the location
*/
function stopLocation() {
var geo = navigator.geolocation;
if (!geo) {
alert('navigator.geolocation object is missing.');
return;
}
setLocationStatus("Stopped");
if (watchLocationId) {
geo.clearWatch(watchLocationId);
watchLocationId = null;
}
}
/**
* Start watching location

@@ -298,18 +336,2 @@ */

/**
* Stop watching the location
*/
var stopLocation = function () {
var geo = navigator.geolocation;
if (!geo) {
alert('navigator.geolocation object is missing.');
return;
}
setLocationStatus("Stopped");
if (watchLocationId) {
geo.clearWatch(watchLocationId);
watchLocationId = null;
}
};
/**
* Get current location

@@ -346,20 +368,2 @@ */

/**
* Set location status
*/
var setLocationStatus = function (status) {
document.getElementById('location_status').innerHTML = status;
};
var setLocationDetails = function (p) {
var date = (new Date(p.timestamp));
document.getElementById('latitude').innerHTML = p.coords.latitude;
document.getElementById('longitude').innerHTML = p.coords.longitude;
document.getElementById('altitude').innerHTML = p.coords.altitude;
document.getElementById('accuracy').innerHTML = p.coords.accuracy;
document.getElementById('heading').innerHTML = p.coords.heading;
document.getElementById('speed').innerHTML = p.coords.speed;
document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
};
/******************************************************************************/

@@ -430,4 +434,4 @@

contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed
+ altitude_accuracy + time + note + actions;
contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed +
altitude_accuracy + time + note + actions;

@@ -434,0 +438,0 @@ createActionButton('Get Location', function () {

@@ -22,3 +22,2 @@ /*

var exec = cordova.require('cordova/exec');

@@ -28,4 +27,7 @@ var utils = require('cordova/utils');

// Native watchPosition method is called async after permissions prompt.
// So we use additional map and own ids to return watch id synchronously.
var pluginToNativeWatchMap = {};
module.exports = {
getCurrentPosition: function(success, error, args) {

@@ -72,5 +74,1 @@ var win = function() {

};
// Native watchPosition method is called async after permissions prompt.
// So we use additional map and own ids to return watch id synchronously.
var pluginToNativeWatchMap = {};

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc