You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2014/05/20 20:50:53 UTC
[2/8] git commit: proper implementation for firefoxos
proper implementation for firefoxos
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/61062b90
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/61062b90
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/61062b90
Branch: refs/heads/master
Commit: 61062b906eab51792ca47a9928ff13b67712a377
Parents: 459a01c
Author: James Long <lo...@gmail.com>
Authored: Mon Nov 4 13:50:38 2013 -0500
Committer: James Long <lo...@gmail.com>
Committed: Mon Nov 4 13:50:38 2013 -0500
----------------------------------------------------------------------
plugin.xml | 21 ++++++++++++---
src/firefoxos/GeolocationProxy.js | 49 +++++++++++++++++++++-------------
2 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/61062b90/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index fa074bd..dd33874 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -132,18 +132,33 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<DeviceCapability Name="location" />
</config-file>
</platform>
-
+
<!-- firefoxos -->
<platform name="firefoxos">
<config-file target="config.xml" parent="/*">
<feature name="Geolocation">
<param name="firefoxos-package" value="Geolocation" />
</feature>
- </config-file>
+ </config-file>
+
<js-module src="src/firefoxos/GeolocationProxy.js" name="GeolocationProxy">
<runs />
</js-module>
- </platform>
+ <js-module src="www/Coordinates.js" name="Coordinates">
+ <clobbers target="Coordinates" />
+ </js-module>
+ <js-module src="www/PositionError.js" name="PositionError">
+ <clobbers target="PositionError" />
+ </js-module>
+
+ <js-module src="www/Position.js" name="Position">
+ <clobbers target="Position" />
+ </js-module>
+
+ <js-module src="www/geolocation.js" name="geolocation">
+ <clobbers target="navigator.geolocation" />
+ </js-module>
+ </platform>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/61062b90/src/firefoxos/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/GeolocationProxy.js b/src/firefoxos/GeolocationProxy.js
index 0f05f02..c5803de 100644
--- a/src/firefoxos/GeolocationProxy.js
+++ b/src/firefoxos/GeolocationProxy.js
@@ -21,29 +21,40 @@
// latest geolocation spec can be found here: http://www.w3.org/TR/geolocation-API/
+var idsMap = {};
+
module.exports = {
+ getLocation: function(success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ geo.getCurrentPosition(success, error, {
+ enableHighAccuracy: args[0],
+ maximumAge: args[1]
+ });
+ },
- getCurrentPosition: function(win, geolocationError, args) {
- win(position);
+ addWatch: function(success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ var id = args[0];
+ var nativeId = geo.watchPosition(success, error, {
+ enableHighAccuracy: args[1]
+ });
+
+ idsMap[id] = nativeId;
},
-
- geolocationError(error) {
- switch(error.code) {
- case error.TIMEOUT:
- console.log("geolocation timeout");
- break;
- case error.POSITION_UNAVAILABLE:
- console.log("position unavailable");
- break;
- case error:.PERMISSION_DENIED:
- console.log("permission denied");
- break;
- default:
- console.log("unknown error");
- break;
+
+ clearWatch: function(success, error, args) {
+ var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
+ var id = args[0];
+
+ if(id in idsMap) {
+ geo.clearWatch(idsMap[id]);
+ delete idsMap[id];
}
- }
+ if(success) {
+ success();
+ }
+ }
};
-require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);
\ No newline at end of file
+require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);