Mercurial > gemma
comparison client/src/store/fairway.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 | 48ae4458710d |
children | bc55ffaeb639 |
comparison
equal
deleted
inserted
replaced
1236:ec4b06d3a3a8 | 1237:74562dc29e10 |
---|---|
103 actions: { | 103 actions: { |
104 clearSelection({ commit, dispatch, rootGetters, rootState }) { | 104 clearSelection({ commit, dispatch, rootGetters, rootState }) { |
105 dispatch("bottlenecks/setSelectedBottleneck", null, { root: true }); | 105 dispatch("bottlenecks/setSelectedBottleneck", null, { root: true }); |
106 commit("clearCurrentProfile"); | 106 commit("clearCurrentProfile"); |
107 commit("application/showSplitscreen", false, { root: true }); | 107 commit("application/showSplitscreen", false, { root: true }); |
108 commit("map/cutMode", false, { root: true }); | 108 rootState.map.cutTool.setActive(false); |
109 rootGetters["map/getLayerByName"]("Cut Tool") | 109 rootGetters["map/getLayerByName"]("Cut Tool") |
110 .data.getSource() | 110 .data.getSource() |
111 .clear(); | 111 .clear(); |
112 rootState.map.openLayersMap.removeInteraction(rootState.map.cutTool); | |
113 }, | 112 }, |
114 loadProfile({ commit, state }, survey) { | 113 loadProfile({ commit, state }, survey) { |
115 return new Promise((resolve, reject) => { | 114 return new Promise((resolve, reject) => { |
116 const profileLine = new LineString([state.startPoint, state.endPoint]); | 115 const profileLine = new LineString([state.startPoint, state.endPoint]); |
117 const geoJSON = generateFeatureRequest( | 116 const geoJSON = generateFeatureRequest( |
186 }) | 185 }) |
187 .then(() => { | 186 .then(() => { |
188 commit("application/showSplitscreen", true, { root: true }); | 187 commit("application/showSplitscreen", true, { root: true }); |
189 }) | 188 }) |
190 .catch(error => { | 189 .catch(error => { |
191 console.log(error); | |
192 const { status, data } = error.response; | 190 const { status, data } = error.response; |
193 displayError({ | 191 displayError({ |
194 title: "Backend Error", | 192 title: "Backend Error", |
195 message: `${status}: ${data.message || data}` | 193 message: `${status}: ${data.message || data}` |
196 }); | 194 }); |