comparison client/src/store/map.js @ 2132:7a2eedc182f7

staging: zoomable stretches. zoomToExtent etd
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 05 Feb 2019 16:50:59 +0100
parents ea5a0e771b71
children 602c2096c078
comparison
equal deleted inserted replaced
2131:c6a4990a1d93 2132:7a2eedc182f7
27 import { HTTP } from "../lib/http"; 27 import { HTTP } from "../lib/http";
28 import { fromLonLat } from "ol/proj"; 28 import { fromLonLat } from "ol/proj";
29 import { getLength, getArea } from "ol/sphere.js"; 29 import { getLength, getArea } from "ol/sphere.js";
30 import { unByKey } from "ol/Observable"; 30 import { unByKey } from "ol/Observable";
31 import { getCenter } from "ol/extent"; 31 import { getCenter } from "ol/extent";
32 import { transformExtent } from "ol/proj.js";
33 import bbox from "@turf/bbox";
32 import app from "../main"; 34 import app from "../main";
33 35
34 // initial state 36 // initial state
35 const init = () => { 37 const init = () => {
36 return { 38 return {
446 state.polygonTool = polygonTool; 448 state.polygonTool = polygonTool;
447 }, 449 },
448 cutTool: (state, cutTool) => { 450 cutTool: (state, cutTool) => {
449 state.cutTool = cutTool; 451 state.cutTool = cutTool;
450 }, 452 },
451 moveToExtent: (state, { extent, zoom, preventZoomOut }) => { 453 moveToExtent: (state, { feature, zoom, preventZoomOut }) => {
454 const boundingBox = bbox(feature.geometry);
455 const extent = transformExtent(boundingBox, "EPSG:4326", "EPSG:3857");
452 let view = state.openLayersMap.getView(); 456 let view = state.openLayersMap.getView();
453 const currentZoom = view.getZoom(); 457 const currentZoom = view.getZoom();
454 view.fit(extent, { 458 view.fit(extent, {
455 maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, 459 maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom,
456 duration: 700 460 duration: 700