Fix/workaround/whatever various map bugs by reloading map when opening, close #11

master
Skylar Ittner 5 years ago
parent 6c43a7df6e
commit d3d41a5e75

@ -67,32 +67,7 @@ $("#addpackagebtn").click(function () {
} }
var address = ($("input[name=number]").val() + " " + $("input[name=street]").val()).toUpperCase(); var address = ($("input[name=number]").val() + " " + $("input[name=street]").val()).toUpperCase();
$.getJSON(SETTINGS.geocodeapi, { addPackageByAddress(address, $("input[name=citystate]").val().toUpperCase());
address: address + " " + $("input[name=citystate]").val().toUpperCase()
}, function (resp) {
if (resp.status == "OK") {
if (resp.accuracy.ok) {
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
} else {
playSound("error");
app.dialog.confirm(
"The address \"" + address + "\" couldn't be reliably located. Add it anyways?",
"Accuracy Warning",
function (ok) {
if (resp.address.street == "") {
addPackage(address, resp.coords[0], resp.coords[1]);
} else {
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
}
}
);
}
} else {
playSound("error");
app.dialog.alert(resp.message, "Error");
}
});
}); });
// Restore user's last entered city/state combo // Restore user's last entered city/state combo

@ -18,11 +18,16 @@ function createMap() {
function reloadMap() { function reloadMap() {
try { try {
if (map != null && typeof map != 'undefined') { if (map != null && typeof map != 'undefined') {
var mapcenter = map.getCenter();
var mapzoom = map.getZoom();
map.off(); map.off();
map.remove(); map.remove();
map = null; map = null;
createMap();
map.setView(mapcenter, mapzoom);
} else {
createMap();
} }
createMap();
} catch (ex) { } catch (ex) {
// oh well ¯\(°_o)/¯ // oh well ¯\(°_o)/¯
} }

@ -38,4 +38,33 @@ function countRemainingPackages() {
} }
} }
return undelivered; return undelivered;
}
function addPackageByAddress(address, citystate) {
$.getJSON(SETTINGS.geocodeapi, {
address: address + " " + citystate
}, function (resp) {
if (resp.status == "OK") {
if (resp.accuracy.ok) {
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
} else {
playSound("error");
app.dialog.confirm(
"The address \"" + address + "\" couldn't be reliably located. Add it anyways?",
"Accuracy Warning",
function (ok) {
if (resp.address.street == "") {
addPackage(address, resp.coords[0], resp.coords[1]);
} else {
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
}
}
);
}
} else {
playSound("error");
app.dialog.alert(resp.message, "Error");
}
});
} }

@ -13,6 +13,11 @@
</a> </a>
</div> </div>
<div class="title">Map</div> <div class="title">Map</div>
<div class="right">
<a class="link" onclick="reloadMap()">
<i class="fas fa-sync-alt"></i>
</a>
</div>
</div> </div>
</div> </div>

@ -60,9 +60,7 @@ var routes = [
keepAlive: true, keepAlive: true,
on: { on: {
pageAfterIn: function () { pageAfterIn: function () {
if (map == null) { reloadMap();
createMap();
}
} }
} }
}, },

Loading…
Cancel
Save