comparison client/src/store/map.js @ 1237:74562dc29e10

refactored drawtool The map interactions (ol/interaction/Draw) were previously always removed and re-created. Now there are created and added to the map once and their active flag is used to toggle the tools. Results in cleaner code and easier separation of the buttons in the future.
author Markus Kottlaender <markus@intevation.de>
date Tue, 20 Nov 2018 13:03:24 +0100
parents 49740dcba52c
children c14353e2cdb9
comparison
equal deleted inserted replaced
1236:ec4b06d3a3a8 1237:74562dc29e10
36 namespaced: true, 36 namespaced: true,
37 state: { 37 state: {
38 openLayersMap: null, 38 openLayersMap: null,
39 identifiedFeatures: [], // map features identified by clicking on the map 39 identifiedFeatures: [], // map features identified by clicking on the map
40 currentMeasurement: null, // distance or area from drawTool 40 currentMeasurement: null, // distance or area from drawTool
41 drawMode: null, // null, "LineString", "Polygon" 41 lineTool: null, // open layers interaction object (Draw)
42 drawTool: null, // open layers interaction object (Draw) 42 polygonTool: null, // open layers interaction object (Draw)
43 cutMode: false, // true or false
44 cutTool: null, // open layers interaction object (Draw) 43 cutTool: null, // open layers interaction object (Draw)
45 layers: [ 44 layers: [
46 { 45 {
47 name: "Open Streetmap", 46 name: "Open Streetmap",
48 data: new TileLayer({ 47 data: new TileLayer({
355 state.identifiedFeatures = identifiedFeatures; 354 state.identifiedFeatures = identifiedFeatures;
356 }, 355 },
357 setCurrentMeasurement: (state, measurement) => { 356 setCurrentMeasurement: (state, measurement) => {
358 state.currentMeasurement = measurement; 357 state.currentMeasurement = measurement;
359 }, 358 },
360 drawMode: (state, mode) => { 359 lineTool: (state, lineTool) => {
361 state.drawMode = mode; 360 state.lineTool = lineTool;
362 }, 361 },
363 drawTool: (state, drawTool) => { 362 polygonTool: (state, polygonTool) => {
364 state.drawTool = drawTool; 363 state.polygonTool = polygonTool;
365 },
366 cutMode: (state, mode) => {
367 state.cutMode = mode;
368 }, 364 },
369 cutTool: (state, cutTool) => { 365 cutTool: (state, cutTool) => {
370 state.cutTool = cutTool; 366 state.cutTool = cutTool;
371 }, 367 },
372 moveMap: (state, { coordinates, zoom, preventZoomOut }) => { 368 moveMap: (state, { coordinates, zoom, preventZoomOut }) => {