Skip to content
Permalink
Browse files
CB-8085 Fix geolocation plugin on Windows
  • Loading branch information
sgrebnov committed Nov 26, 2014
1 parent 7dc4400 commit e3f9685993975cdc59283e4d5b0940cc293ed83b
Showing 1 changed file with 10 additions and 2 deletions.
@@ -1,4 +1,4 @@
/*
/*
* Copyright 2013 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,7 +111,7 @@ module.exports = {
highAccuracy = args[1],

onPositionChanged = function (e) {
success(createResult(e.position));
success(createResult(e.position), {keepCallback: true});
},

onStatusChanged = function (e) {
@@ -142,6 +142,14 @@ module.exports = {
Windows.Devices.Geolocation.PositionAccuracy.high :
Windows.Devices.Geolocation.PositionAccuracy.default;

if (cordova.platformId == 'windows' && WinJS.Utilities.isPhone) {
// on Windows Phone 8.1 '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
loc.movementThreshold = loc.movementThreshold || 1; // 1 meter
}

loc.addEventListener("positionchanged", onPositionChanged);
loc.addEventListener("statuschanged", onStatusChanged);

0 comments on commit e3f9685

Please sign in to comment.