comparison client/src/store/map.js @ 2206:2e64d1be3dbc pdf-export

staging: zoomable stretches. zoomToExtent etd
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 05 Feb 2019 16:50:59 +0100
parents cac5d2fba591
children 763c520a7717
comparison
equal deleted inserted replaced
2205:59c21dee6315 2206:2e64d1be3dbc
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 {
392 state.polygonTool = polygonTool; 394 state.polygonTool = polygonTool;
393 }, 395 },
394 cutTool: (state, cutTool) => { 396 cutTool: (state, cutTool) => {
395 state.cutTool = cutTool; 397 state.cutTool = cutTool;
396 }, 398 },
397 moveToExtent: (state, { extent, zoom, preventZoomOut }) => { 399 moveToExtent: (state, { feature, zoom, preventZoomOut }) => {
400 const boundingBox = bbox(feature.geometry);
401 const extent = transformExtent(boundingBox, "EPSG:4326", "EPSG:3857");
398 let view = state.openLayersMap.getView(); 402 let view = state.openLayersMap.getView();
399 const currentZoom = view.getZoom(); 403 const currentZoom = view.getZoom();
400 view.fit(extent, { 404 view.fit(extent, {
401 maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, 405 maxZoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom,
402 duration: 700 406 duration: 700