in src/windows/GeolocationProxy.js [130:187]
addWatch: function (success, fail, args, env) {
ensureAndCreateLocator().done(function (loc) {
const clientId = args[0];
const highAccuracy = args[1];
const onPositionChanged = function (e) {
success(createResult(e.position), { keepCallback: true });
};
const onStatusChanged = function (e) {
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.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;
}
};
loc.desiredAccuracy = highAccuracy
? Windows.Devices.Geolocation.PositionAccuracy.high
: Windows.Devices.Geolocation.PositionAccuracy.default;
if (cordova.platformId === 'windows') {
// eslint-disable-line no-undef
// 'positionchanged' event fails with error below if movementThreshold is not set
// JavaScript runtime error: Operation aborted
// You must set the MovementThreshold property or the ReportInterval property before adding event handlers.
// WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers
if (Number.EPSILON) {
loc.movementThreshold = Number.EPSILON;
} else {
loc.movementThreshold = FALLBACK_EPSILON;
}
}
loc.addEventListener('positionchanged', onPositionChanged);
loc.addEventListener('statuschanged', onStatusChanged);
callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged };
locs[clientId] = loc;
}, fail);
},