Reload map when adding packages (fixes glitch), adjust max zoom

This commit is contained in:
Skylar Ittner 2019-09-10 22:00:44 -06:00
parent 6b1f3a1486
commit 980abf000e
4 changed files with 17 additions and 6 deletions

View File

@ -25,7 +25,7 @@ function addPackage(address, latitude, longitude) {
}); });
if (map != null) { if (map != null) {
map.updatePackageLayer(packages); reloadMap();
} }
} }

View File

@ -11,6 +11,19 @@ function createMap() {
map.updatePackageLayer(packages); map.updatePackageLayer(packages);
} }
/**
* Destroy and re-create the map.
* @returns {undefined}
*/
function reloadMap() {
if (map != null) {
map.off();
map.remove();
map = null;
}
createMap();
}
/** /**
* Make the toggle button on the popup sheet do things * Make the toggle button on the popup sheet do things
*/ */

View File

@ -8,7 +8,7 @@ function leafletMap() {
var map = L.map('mapbox', { var map = L.map('mapbox', {
zoomSnap: 0.25, zoomSnap: 0.25,
minZoom: 1, minZoom: 1,
maxZoom: 20, maxZoom: 19,
zoom: 12, zoom: 12,
center: L.latLng(46.5966, -112.0180), center: L.latLng(46.5966, -112.0180),
attributionControl: true, attributionControl: true,
@ -36,7 +36,7 @@ function leafletMap() {
} else { } else {
L.tileLayer(mapSources[localStorage.getItem("mapsource")], { L.tileLayer(mapSources[localStorage.getItem("mapsource")], {
minZoom: 1, minZoom: 1,
maxZoom: 20 maxZoom: 19
}).addTo(map); }).addTo(map);
} }

View File

@ -16,9 +16,7 @@ function confirmDeletePackage(id) {
"Confirm", "Confirm",
function () { function () {
// delete // delete
packages.splice(id, 1); deletePackage(id);
localStorage.setItem("packages", JSON.stringify(packages));
loadPackageList();
}, },
function () { function () {
// cancel // cancel