Reload map when style setting changed (close #1)

This commit is contained in:
Skylar Ittner 2019-09-11 19:29:20 -06:00
parent 57da01c03c
commit 46da8239b4
2 changed files with 11 additions and 6 deletions

View File

@ -16,12 +16,16 @@ function createMap() {
* @returns {undefined} * @returns {undefined}
*/ */
function reloadMap() { function reloadMap() {
if (map != null) { try {
map.off(); if (map != null && typeof map != 'undefined') {
map.remove(); map.off();
map = null; map.remove();
map = null;
}
createMap();
} catch (ex) {
// oh well ¯\(°_o)/¯
} }
createMap();
} }
/** /**

View File

@ -145,7 +145,8 @@ function pickMapSource() {
return; return;
} }
localStorage.setItem("mapsource", mapsource); localStorage.setItem("mapsource", mapsource);
// Re-init map to load new style
reloadMap();
} }
}).open(); }).open();
} }