Skip to content
Permalink
Browse files
CB-5729 [BlackBerry10] Update GeolocationProxy to return collapsed ob…
…ject
  • Loading branch information
bryanhiggins committed Jan 6, 2014
1 parent 8a8aa20 commit f2a355d32b9014520a054a595fa8b372fabaf763
Showing 1 changed file with 21 additions and 13 deletions.
@@ -19,43 +19,51 @@
*
*/

var idsMap = {};
var idsMap = {},
geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');

module.exports = {

getLocation: function(success, error, args) {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'),
successCallback = function (position) {
success(position.coords);
};
var successCallback = function (result) {
var pos = result.coords;
pos.timestamp = result.timestamp;
if (success) {
success(pos);
}
};
geo.getCurrentPosition(successCallback, error, {
enableHighAccuracy: args[0],
maximumAge: args[1]
});
},

addWatch: function(success, error, args) {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'),
id = args[0],
nativeId = geo.watchPosition(success, error, {
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]
});

idsMap[id] = nativeId;
},

clearWatch: function(success, error, args) {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'),
id = args[0];

var id = args[0];
if(id in idsMap) {
geo.clearWatch(idsMap[id]);
delete idsMap[id];
}

if(success) {
success();
}
}

};

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

0 comments on commit f2a355d

Please sign in to comment.