Mercurial > gemma
diff client/src/store/map.js @ 3079:57255fda7594
client: compare surveys on map
The compare survey is now displayed in a second map.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Thu, 18 Apr 2019 12:40:42 +0200 |
parents | 71129566acdf |
children | 9107c959bb3b |
line wrap: on
line diff
--- a/client/src/store/map.js Thu Apr 18 10:17:36 2019 +0200 +++ b/client/src/store/map.js Thu Apr 18 12:40:42 2019 +0200 @@ -52,8 +52,10 @@ namespaced: true, state: init(), getters: { - openLayersMap: state => { - return state.openLayersMaps.length ? state.openLayersMaps[0] : null; + openLayersMap: state => id => { + return state.openLayersMaps.find( + map => map.getTarget() === "map-" + (id || "main") + ); }, filteredIdentifiedFeatures: state => { return state.identifiedFeatures.filter(f => f.getId()); @@ -486,12 +488,11 @@ } }); }, - moveToBoundingBox({ getters }, { boundingBox, zoom, preventZoomOut }) { + moveToBoundingBox({ state }, { boundingBox, zoom, preventZoomOut }) { const extent = transformExtent(boundingBox, "EPSG:4326", "EPSG:3857"); - let view = getters.openLayersMap.getView(); - const currentZoom = view.getZoom(); + const currentZoom = state.syncedView.getZoom(); zoom = zoom || currentZoom; - view.fit(extent, { + state.syncedView.fit(extent, { maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, duration: 700 }); @@ -500,13 +501,12 @@ const boundingBox = bbox(feature.geometry); dispatch("moveToBoundingBox", { boundingBox, zoom, preventZoomOut }); }, - moveMap({ getters }, { coordinates, zoom, preventZoomOut }) { - let view = getters.openLayersMap.getView(); - const currentZoom = view.getZoom(); + moveMap({ state }, { coordinates, zoom, preventZoomOut }) { + const currentZoom = state.syncedView.getZoom(); zoom = zoom || currentZoom; - view.animate({ + state.syncedView.animate({ zoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, - center: fromLonLat(coordinates, view.getProjection()), + center: fromLonLat(coordinates, state.syncedView.getProjection()), duration: 700 }); }