From 34962dd7d9607fbbe61653892f1b7edf148e7257 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Tue, 26 Nov 2019 08:42:00 +0100 Subject: [PATCH] fix map reload issue --- static/js/components/Map.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/static/js/components/Map.js b/static/js/components/Map.js index 02a354a..3401a90 100644 --- a/static/js/components/Map.js +++ b/static/js/components/Map.js @@ -22,6 +22,8 @@ function setupMap(vnode){ map.on('zoomend', updateHash); map.on('moveend', updateHash); + + return map; } export default { @@ -30,34 +32,24 @@ export default { }, oncreate(vnode){ - setupMap(vnode); - }, - - onbeforeupdate(newVnode) { - const center = newVnode.state.map.getCenter(); - const newAattrs = newVnode.attrs; - - return newAattrs.layerId != layerManager.getCurrentLayer().id || - newAattrs.zoom != newVnode.state.map.getZoom() || - Math.abs(newAattrs.lat - center.lat) > 2 || - Math.abs(newAattrs.lat - center.lat) > 2; + this.map = setupMap(vnode); }, onupdate(vnode){ if (vnode.attrs.layerId != layerManager.getCurrentLayer().id){ //layer changed, recreate map - vnode.state.map.remove(); + this.map.remove(); layerManager.setLayerId(vnode.attrs.layerId); setupMap(vnode); } else { //position/zoom change - vnode.state.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom); + //this.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom); } }, onremove(vnode){ - vnode.state.map.remove(); + this.map.remove(); } };