Skip to content
Permalink
Browse files
  • Loading branch information
purplecabbage committed Aug 7, 2014
2 parents 05c32c1 + 4137f9d commit a8e9efe93c704a2ef975febed39e8df669eeff79
Showing 2 changed files with 67 additions and 23 deletions.
@@ -192,14 +192,55 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
<DeviceCapability Name="location" />
</config-file>

<js-module src="src/windows/GeolocationProxy.js" name="GeolocationProxy">
<runs />
</js-module>

<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="src/windows8/GeolocationProxy.js" name="GeolocationProxy">
<merges target="" />

<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>

<!-- windows universal apps (Windows 8.1, Windows Phone 8.1, Windows 8.0) -->
<platform name="windows">
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
<DeviceCapability Name="location" />
</config-file>

<js-module src="src/windows/GeolocationProxy.js" name="GeolocationProxy">
<runs />
</js-module>

<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>

<!-- firefoxos -->
<platform name="firefoxos">
<config-file target="config.xml" parent="/*">
@@ -48,6 +48,27 @@ function createErrorCode() {
break;
}
}
function createResult(pos) {
var res = {
accuracy: pos.coordinate.accuracy,
heading: pos.coordinate.heading,
velocity: pos.coordinate.speed,
altitudeAccuracy: pos.coordinate.altitudeAccuracy,
timestamp: pos.coordinate.timestamp
}

if (pos.coordinate.point) {
res.latitude = pos.coordinate.point.position.latitude;
res.longitude = pos.coordinate.point.position.longitude;
res.altitude = pos.coordinate.point.position.altitude;
} else { // compatibility with old windows8.0 api
res.latitude = pos.coordinate.latitude;
res.longitude = pos.coordinate.longitude;
res.altitude = pos.coordinate.altitude;
}

return res;
}

module.exports = {
getLocation: function (success, fail, args, env) {
@@ -65,16 +86,7 @@ module.exports = {

loc.getGeopositionAsync().then(
function (pos) {
success({
latitude: pos.coordinate.latitude,
longitude: pos.coordinate.longitude,
altitude: pos.coordinate.altitude,
accuracy: pos.coordinate.accuracy,
heading: pos.coordinate.heading,
velocity: pos.coordinate.speed,
altitudeAccuracy: pos.coordinate.altitudeAccuracy,
timestamp: pos.coordinate.timestamp
});
success(createResult(pos));
},
function (err) {
fail({
@@ -99,16 +111,7 @@ module.exports = {
highAccuracy = args[1],

onPositionChanged = function (e) {
success({
latitude: e.position.coordinate.latitude,
longitude: e.position.coordinate.longitude,
altitude: e.position.coordinate.altitude,
accuracy: e.position.coordinate.accuracy,
heading: e.position.coordinate.heading,
velocity: e.position.coordinate.speed,
altitudeAccuracy: e.position.coordinate.altitudeAccuracy,
timestamp: e.position.coordinate.timestamp
});
success(createResult(e.position));
},

onStatusChanged = function (e) {
@@ -160,4 +163,4 @@ module.exports = {
}
};

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

0 comments on commit a8e9efe

Please sign in to comment.