Pre-populate user location with GeoIP data from the server

master
Skylar Ittner 5 years ago
parent 66161eebf8
commit 3967a15485

@ -20,6 +20,21 @@ if (localStorage.getItem("user_latitude") != null && localStorage.getItem("user_
userPosition.coords.longitude = localStorage.getItem("user_longitude");
}
// Request the user's IP geolocation as a poor substitute for an actual location
// Should improve UX for weather tool at least
$.ajax({
url: SETTINGS.geoipapi,
dataType: 'json',
timeout: 10 * 1000,
success: function (resp) {
if (resp.status == "OK" && userPosition.coords.accuracy > 99999) {
userPosition.coords.latitude = resp.location.latitude;
userPosition.coords.longitude = resp.location.longitude;
userPosition.coords.accuracy = 99999;
}
}
});
var geoerrorcount = 0;
var mapLocationControlStarted = false;
@ -53,7 +68,7 @@ if ("geolocation" in navigator) {
if (packages[i].lastAlert > currentTimestamp - alertinterval) {
continue;
}
if (getUndeliveredCount(packages[i]) == 0) {
continue;
}

@ -80,5 +80,6 @@ var SETTINGS = {
},
geocodeapi: "https://apis.netsyms.net/packagehelper/geocode.php",
trackingapi: "https://apis.netsyms.net/packagehelper/track.php",
weatherapi: "https://apis.netsyms.net/packagehelper/weather.php"
weatherapi: "https://apis.netsyms.net/packagehelper/weather.php",
geoipapi: "https://apis.netsyms.net/packagehelper/geoip.php"
}

Loading…
Cancel
Save