+
+geofake = {
+ tracking: false,
+ watchPosition: function(aSuccessCallback, aErrorCallback, aPrefObject) {
+ this.tracking = true;
+ var watchCall = function() {
+ aSuccessCallback({timestamp: Date.now(),
+ coords: {latitude: 48.208174, // + Math.random() - .5,
+ longitude: 16.373819, // + Math.random() - .5,
+ accuracy: 20}});
+ if (geofake.tracking)
+ setTimeout(watchCall, 1000);
+ };
+ setTimeout(watchCall, 1000);
+ return "foo";
+ },
+ clearWatch: function(aID) {
+ this.tracking = false;
+ }
+}
+
+function startTracking() {
+ if (navigator.geolocation) {
+ //gGeoWatchID = geofake.watchPosition(
+ gGeoWatchID = navigator.geolocation.watchPosition(
+ function(position) {
+ // Coords spec: https://developer.mozilla.org/en/XPCOM_Interface_Reference/NsIDOMGeoPositionCoords
+ gTrack.push({time: position.timestamp, coords: position.coords});
+ drawTrackPoint(position.coords.latitude, position.coords.longitude);
+ },
+ function(error) {
+ // Ignore erros for the moment, but this is good for debugging.
+ // See https://developer.mozilla.org/en/Using_geolocation#Handling_errors
+ document.getElementById("debug").textContent = error.message;
+ },
+ {enableHighAccuracy: true}
+ );
+ }
+}
+
+function endTracking() {
+ if (gGeoWatchID) {
+ navigator.geolocation.clearWatch(gGeoWatchID);
+ }
+}