changeset 2108:cac5d2fba591

bbox tool from turfjs added. zoomToExtent function added to map.js
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 04 Feb 2019 17:04:33 +0100
parents 6747a4cf3639
children 86c88fc0ff5e
files client/package.json client/src/components/staging/StagingDetail.vue client/src/store/map.js client/yarn.lock
diffstat 4 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/package.json	Mon Feb 04 16:00:02 2019 +0100
+++ b/client/package.json	Mon Feb 04 17:04:33 2019 +0100
@@ -21,6 +21,7 @@
     "@fortawesome/free-regular-svg-icons": "^5.5.0",
     "@fortawesome/free-solid-svg-icons": "^5.5.0",
     "@fortawesome/vue-fontawesome": "^0.1.2",
+    "@turf/bbox": "^6.0.1",
     "@turf/center": "^6.0.1",
     "@turf/distance": "^6.0.1",
     "@turf/helpers": "^6.1.4",
--- a/client/src/components/staging/StagingDetail.vue	Mon Feb 04 16:00:02 2019 +0100
+++ b/client/src/components/staging/StagingDetail.vue	Mon Feb 04 17:04:33 2019 +0100
@@ -306,6 +306,13 @@
       const { coordinates } = center(this.bottlenecks[index]).geometry;
       this.moveMap(coordinates);
     },
+    moveToExtent(geometry) {
+      this.$store.commit("map/moveToExtent", {
+        extent: geometry,
+        zoom: 17,
+        preventZoomOut: true
+      });
+    },
     moveMap(coordinates) {
       this.$store.commit("map/moveMap", {
         coordinates: coordinates,
--- a/client/src/store/map.js	Mon Feb 04 16:00:02 2019 +0100
+++ b/client/src/store/map.js	Mon Feb 04 17:04:33 2019 +0100
@@ -394,6 +394,14 @@
     cutTool: (state, cutTool) => {
       state.cutTool = cutTool;
     },
+    moveToExtent: (state, { extent, zoom, preventZoomOut }) => {
+      let view = state.openLayersMap.getView();
+      const currentZoom = view.getZoom();
+      view.fit(extent, {
+        maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom,
+        duration: 700
+      });
+    },
     moveMap: (state, { coordinates, zoom, preventZoomOut }) => {
       let view = state.openLayersMap.getView();
       const currentZoom = view.getZoom();
--- a/client/yarn.lock	Mon Feb 04 16:00:02 2019 +0100
+++ b/client/yarn.lock	Mon Feb 04 17:04:33 2019 +0100
@@ -710,7 +710,7 @@
   resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
   integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
 
-"@turf/bbox@*", "@turf/bbox@6.x":
+"@turf/bbox@*", "@turf/bbox@6.x", "@turf/bbox@^6.0.1":
   version "6.0.1"
   resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-6.0.1.tgz#b966075771475940ee1c16be2a12cf389e6e923a"
   integrity sha512-EGgaRLettBG25Iyx7VyUINsPpVj1x3nFQFiGS3ER8KCI1MximzNLsam3eXRabqQDjyAKyAE1bJ4EZEpGvspQxw==