Use last known location before GPS warms up (close #19)
This commit is contained in:
parent
afb607a618
commit
385f0ae535
@ -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 geoerrorcount = 0;
|
||||||
|
|
||||||
var mapLocationControlStarted = false;
|
var mapLocationControlStarted = false;
|
||||||
@ -21,6 +27,8 @@ var mapLocationControlStarted = false;
|
|||||||
if ("geolocation" in navigator) {
|
if ("geolocation" in navigator) {
|
||||||
navigator.geolocation.watchPosition(function (position) {
|
navigator.geolocation.watchPosition(function (position) {
|
||||||
userPosition = position;
|
userPosition = position;
|
||||||
|
localStorage.setItem("user_latitude", userPosition.coords.latitude);
|
||||||
|
localStorage.setItem("user_longitude", userPosition.coords.longitude);
|
||||||
if (mapLocationControlStarted) {
|
if (mapLocationControlStarted) {
|
||||||
//setMapLocation(position.coords.latitude, position.coords.longitude);
|
//setMapLocation(position.coords.latitude, position.coords.longitude);
|
||||||
// Don't refresh at an interval less than ten seconds
|
// Don't refresh at an interval less than ten seconds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user