|
|
|
@ -14,6 +14,12 @@ var userPosition = {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Preload last known location while GPS warms up
|
|
|
|
|
if (localStorage.getItem("user_latitude") != null && localStorage.getItem("user_longitude") != null) {
|
|
|
|
|
userPosition.coords.latitude = localStorage.getItem("user_latitude");
|
|
|
|
|
userPosition.coords.longitude = localStorage.getItem("user_longitude");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var geoerrorcount = 0;
|
|
|
|
|
|
|
|
|
|
var mapLocationControlStarted = false;
|
|
|
|
@ -21,6 +27,8 @@ var mapLocationControlStarted = false;
|
|
|
|
|
if ("geolocation" in navigator) {
|
|
|
|
|
navigator.geolocation.watchPosition(function (position) {
|
|
|
|
|
userPosition = position;
|
|
|
|
|
localStorage.setItem("user_latitude", userPosition.coords.latitude);
|
|
|
|
|
localStorage.setItem("user_longitude", userPosition.coords.longitude);
|
|
|
|
|
if (mapLocationControlStarted) {
|
|
|
|
|
//setMapLocation(position.coords.latitude, position.coords.longitude);
|
|
|
|
|
// Don't refresh at an interval less than ten seconds
|
|
|
|
@ -160,14 +168,14 @@ function getDisplayDistance(meters, space) {
|
|
|
|
|
space = true;
|
|
|
|
|
}
|
|
|
|
|
var units = localStorage.getItem("units");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (units == null) {
|
|
|
|
|
units = "metric";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var number = Math.round(meters);
|
|
|
|
|
var label = "m";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (units == "imperial") {
|
|
|
|
|
// Convert to feet
|
|
|
|
|
number = Math.round(number * 3.28084);
|
|
|
|
@ -192,7 +200,7 @@ function getDisplayDistance(meters, space) {
|
|
|
|
|
label = "km";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (space) {
|
|
|
|
|
return number + " " + label;
|
|
|
|
|
}
|
|
|
|
|