Start watching position after finish loading platform code

This commit is contained in:
Skylar Ittner 2021-02-18 23:17:12 -07:00
parent ad869d1b97
commit de2acf34f7
2 changed files with 71 additions and 65 deletions

View File

@ -41,7 +41,8 @@ var geoerrorcount = 0;
var mapLocationControlStarted = false;
if ("geolocation" in navigator) {
function setupPositionWatcher() {
if ("geolocation" in navigator) {
navigator.geolocation.watchPosition(function (position) {
userPosition.coords = position.coords;
userPosition.updated = time();
@ -101,7 +102,7 @@ if ("geolocation" in navigator) {
timeout: 5000,
maximumAge: 0
});
} else {
} else {
geoerrorcount++;
console.log("Warn", "Geolocation error #" + geoerrorcount + ": ", error);
// Stop showing error toasts if they're happening a lot
@ -113,6 +114,7 @@ if ("geolocation" in navigator) {
closeTimeout: 1000 * 3
});
}
}
}
/**

View File

@ -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
applyColorTheme();
// start watching user position after everything's done, hopefully this will make it work
// with ios
setupPositionWatcher();
}, false);
openBrowser = function (url) {
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
@ -266,6 +266,8 @@ function initNW() {
require('nw.gui').Shell.openExternal($(this).attr("href"));
evt.preventDefault();
});
setupPositionWatcher();
}
function initBrowser() {
@ -285,6 +287,8 @@ function initBrowser() {
window.open($(this).attr("href"), "_blank");
evt.preventDefault();
});
setupPositionWatcher();
}
function initPlatform() {