Start watching position after finish loading platform code
This commit is contained in:
parent
ad869d1b97
commit
de2acf34f7
@ -41,7 +41,8 @@ var geoerrorcount = 0;
|
|||||||
|
|
||||||
var mapLocationControlStarted = false;
|
var mapLocationControlStarted = false;
|
||||||
|
|
||||||
if ("geolocation" in navigator) {
|
function setupPositionWatcher() {
|
||||||
|
if ("geolocation" in navigator) {
|
||||||
navigator.geolocation.watchPosition(function (position) {
|
navigator.geolocation.watchPosition(function (position) {
|
||||||
userPosition.coords = position.coords;
|
userPosition.coords = position.coords;
|
||||||
userPosition.updated = time();
|
userPosition.updated = time();
|
||||||
@ -101,7 +102,7 @@ if ("geolocation" in navigator) {
|
|||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
maximumAge: 0
|
maximumAge: 0
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
geoerrorcount++;
|
geoerrorcount++;
|
||||||
console.log("Warn", "Geolocation error #" + geoerrorcount + ": ", error);
|
console.log("Warn", "Geolocation error #" + geoerrorcount + ": ", error);
|
||||||
// Stop showing error toasts if they're happening a lot
|
// Stop showing error toasts if they're happening a lot
|
||||||
@ -113,6 +114,7 @@ if ("geolocation" in navigator) {
|
|||||||
closeTimeout: 1000 * 3
|
closeTimeout: 1000 * 3
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,12 +169,12 @@ function initCordova() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (getStorage("runinbackground") == "true") {
|
|
||||||
// cordova.plugins.foregroundService.start('PackageHelper', 'GPS active');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Make sure the status bar color is set properly
|
// Make sure the status bar color is set properly
|
||||||
applyColorTheme();
|
applyColorTheme();
|
||||||
|
|
||||||
|
// start watching user position after everything's done, hopefully this will make it work
|
||||||
|
// with ios
|
||||||
|
setupPositionWatcher();
|
||||||
}, false);
|
}, false);
|
||||||
openBrowser = function (url) {
|
openBrowser = function (url) {
|
||||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||||
@ -266,6 +266,8 @@ function initNW() {
|
|||||||
require('nw.gui').Shell.openExternal($(this).attr("href"));
|
require('nw.gui').Shell.openExternal($(this).attr("href"));
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setupPositionWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initBrowser() {
|
function initBrowser() {
|
||||||
@ -285,6 +287,8 @@ function initBrowser() {
|
|||||||
window.open($(this).attr("href"), "_blank");
|
window.open($(this).attr("href"), "_blank");
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setupPositionWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPlatform() {
|
function initPlatform() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user