Fix/workaround/whatever various map bugs by reloading map when opening, close #11
This commit is contained in:
parent
6c43a7df6e
commit
d3d41a5e75
@ -67,32 +67,7 @@ $("#addpackagebtn").click(function () {
|
||||
}
|
||||
|
||||
var address = ($("input[name=number]").val() + " " + $("input[name=street]").val()).toUpperCase();
|
||||
$.getJSON(SETTINGS.geocodeapi, {
|
||||
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");
|
||||
}
|
||||
});
|
||||
addPackageByAddress(address, $("input[name=citystate]").val().toUpperCase());
|
||||
});
|
||||
|
||||
// Restore user's last entered city/state combo
|
||||
|
@ -18,11 +18,16 @@ function createMap() {
|
||||
function reloadMap() {
|
||||
try {
|
||||
if (map != null && typeof map != 'undefined') {
|
||||
var mapcenter = map.getCenter();
|
||||
var mapzoom = map.getZoom();
|
||||
map.off();
|
||||
map.remove();
|
||||
map = null;
|
||||
}
|
||||
createMap();
|
||||
map.setView(mapcenter, mapzoom);
|
||||
} else {
|
||||
createMap();
|
||||
}
|
||||
} catch (ex) {
|
||||
// oh well ¯\(°_o)/¯
|
||||
}
|
||||
|
@ -39,3 +39,32 @@ function countRemainingPackages() {
|
||||
}
|
||||
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>
|
||||
</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>
|
||||
|
||||
|
@ -60,9 +60,7 @@ var routes = [
|
||||
keepAlive: true,
|
||||
on: {
|
||||
pageAfterIn: function () {
|
||||
if (map == null) {
|
||||
createMap();
|
||||
}
|
||||
reloadMap();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user