@corpsmap/corpsmap 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/corpsmap.es.js +1 -1
- package/dist/corpsmap.umd.js +1 -1
- package/package.json +2 -1
- package/src/App.jsx +0 -12
- package/src/application-bundles-old/auth-bundle.js +0 -130
- package/src/application-bundles-old/config-bundle.js +0 -29
- package/src/application-bundles-old/ui-bundle.js +0 -406
- package/src/core-plugins/draw-tools-old/create-draw-bundle.js +0 -222
- package/src/core-plugins/draw-tools-old/draw-button.js +0 -189
- package/src/core-plugins/draw-tools-old/draw-label-bundle.js +0 -116
- package/src/core-plugins/draw-tools-old/draw-modify-bundle.js +0 -156
- package/src/core-plugins/draw-tools-old/draw-styles.js +0 -110
- package/src/core-plugins/draw-tools-old/draw-tool-item.js +0 -67
- package/src/core-plugins/draw-tools-old/index.js +0 -32
- package/src/css/_deprecated_bootstrap/css/bootstrap-paper.css +0 -7606
- package/src/css/_deprecated_bootstrap/css/bootstrap-paper.min.css +0 -8083
- package/src/css/_deprecated_bootstrap/css/bootstrap-simplex.min.css +0 -7328
- package/src/css/_deprecated_bootstrap/css/bootstrap-theme.css +0 -587
- package/src/css/_deprecated_bootstrap/css/bootstrap-theme.css.map +0 -1
- package/src/css/_deprecated_bootstrap/css/bootstrap-theme.min.css +0 -6
- package/src/css/_deprecated_bootstrap/css/bootstrap-theme.min.css.map +0 -1
- package/src/css/_deprecated_bootstrap/css/bootstrap.css +0 -7137
- package/src/css/_deprecated_bootstrap/css/bootstrap.css.map +0 -142
- package/src/css/_deprecated_bootstrap/css/bootstrap.min.css +0 -7132
- package/src/css/_deprecated_bootstrap/css/bootstrap.min.css.map +0 -143
- package/src/css/_deprecated_bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/src/css/_deprecated_bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
- package/src/css/_deprecated_bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/src/css/_deprecated_bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/src/css/_deprecated_bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/src/css/_deprecated_bootstrap/js/bootstrap.js +0 -2377
- package/src/css/_deprecated_bootstrap/js/bootstrap.min.js +0 -7
- package/src/css/_deprecated_bootstrap/js/npm.js +0 -13
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import VectorLayer from "ol/layer/Vector";
|
|
2
|
-
import VectorSource from "ol/source/Vector";
|
|
3
|
-
import Draw from "ol/interaction/Draw";
|
|
4
|
-
import { createSelector } from "redux-bundler";
|
|
5
|
-
import styles from "./draw-styles";
|
|
6
|
-
|
|
7
|
-
export default (opts) => {
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
name: "draw",
|
|
10
|
-
type: "Point",
|
|
11
|
-
active: false,
|
|
12
|
-
visible: true,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const config = Object.assign({}, defaultOptions, opts);
|
|
16
|
-
|
|
17
|
-
const uCaseName = config.name.charAt(0).toUpperCase() + config.name.slice(1);
|
|
18
|
-
const baseType = config.name.toUpperCase();
|
|
19
|
-
|
|
20
|
-
// Actions
|
|
21
|
-
const actions = {
|
|
22
|
-
INITIALIZE_START: `${baseType}_INITIALIZE_START`,
|
|
23
|
-
INITIALIZE_FINISH: `${baseType}_INITIALIZE_FINISH`,
|
|
24
|
-
SHOW: `${baseType}_SHOW`,
|
|
25
|
-
HIDE: `${baseType}_HIDE`,
|
|
26
|
-
ACTIVATE: `${baseType}_ACTIVATE`,
|
|
27
|
-
DEACTIVATE: `${baseType}_DEACTIVATE`,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Action Creators
|
|
31
|
-
const doInitialize = `do${uCaseName}Initialize`;
|
|
32
|
-
const doAddLayer = `do${uCaseName}AddLayer`;
|
|
33
|
-
const doRemoveLayer = `do${uCaseName}RemoveLayer`;
|
|
34
|
-
const doAddInteractions = `do${uCaseName}AddInteractions`;
|
|
35
|
-
const doRemoveInteractions = `do${uCaseName}RemoveInteractions`;
|
|
36
|
-
const doToggleVisible = `do${uCaseName}ToggleVisible`;
|
|
37
|
-
const doToggleInteractions = `do${uCaseName}ToggleInteractions`;
|
|
38
|
-
|
|
39
|
-
// Selectors
|
|
40
|
-
const selectLayer = `select${uCaseName}Layer`;
|
|
41
|
-
const selectDrawInteraction = `select${uCaseName}DrawInteraction`;
|
|
42
|
-
const selectModifyInteraction = `select${uCaseName}ModifyselectModifyInteraction`;
|
|
43
|
-
const selectInteractions = `select${uCaseName}InterselectInteractions`;
|
|
44
|
-
const selectActive = `select${uCaseName}Active`;
|
|
45
|
-
const selectVisible = `select${uCaseName}Visible`;
|
|
46
|
-
|
|
47
|
-
// Reactors
|
|
48
|
-
const reactShouldInitialize = `react${uCaseName}ShouldInitialize`;
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
name: config.name,
|
|
52
|
-
|
|
53
|
-
getReducer() {
|
|
54
|
-
const initialData = {
|
|
55
|
-
active: config.active,
|
|
56
|
-
visible: config.visible,
|
|
57
|
-
layer: null,
|
|
58
|
-
drawInteraction: null,
|
|
59
|
-
shouldInitialize: true,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return (state = initialData, { type, payload }) => {
|
|
63
|
-
switch (type) {
|
|
64
|
-
case actions.INITIALIZE_START:
|
|
65
|
-
case actions.INITIALIZE_FINISH:
|
|
66
|
-
case actions.SHOW:
|
|
67
|
-
case actions.HIDE:
|
|
68
|
-
case actions.ACTIVATE:
|
|
69
|
-
case actions.DEACTIVATE:
|
|
70
|
-
return Object.assign({}, state, payload);
|
|
71
|
-
default:
|
|
72
|
-
return state;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
[doInitialize]:
|
|
78
|
-
() =>
|
|
79
|
-
({ dispatch, store }) => {
|
|
80
|
-
dispatch({
|
|
81
|
-
type: actions.INITIALIZE_START,
|
|
82
|
-
payload: {
|
|
83
|
-
shouldInitialize: false,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const source = new VectorSource();
|
|
88
|
-
|
|
89
|
-
const layer = new VectorLayer({
|
|
90
|
-
source: source,
|
|
91
|
-
style: styles(config.type),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const drawInteraction = new Draw({
|
|
95
|
-
source: source,
|
|
96
|
-
type: config.type,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (config.visible) {
|
|
100
|
-
const map = store.selectMap();
|
|
101
|
-
map.addLayer(layer);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
dispatch({
|
|
105
|
-
type: actions.INITIALIZE_FINISH,
|
|
106
|
-
payload: {
|
|
107
|
-
layer: layer,
|
|
108
|
-
drawInteraction: drawInteraction,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
[doAddLayer]:
|
|
114
|
-
() =>
|
|
115
|
-
({ dispatch, store }) => {
|
|
116
|
-
const map = store.selectMap();
|
|
117
|
-
const layer = store[selectLayer]();
|
|
118
|
-
map.addLayer(layer);
|
|
119
|
-
dispatch({
|
|
120
|
-
type: actions.SHOW,
|
|
121
|
-
payload: {
|
|
122
|
-
visible: true,
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
[doRemoveLayer]:
|
|
128
|
-
() =>
|
|
129
|
-
({ dispatch, store }) => {
|
|
130
|
-
const map = store.selectMap();
|
|
131
|
-
const layer = store[selectLayer]();
|
|
132
|
-
map.removeLayer(layer);
|
|
133
|
-
dispatch({
|
|
134
|
-
type: actions.HIDE,
|
|
135
|
-
payload: {
|
|
136
|
-
visible: false,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
[doToggleVisible]:
|
|
142
|
-
() =>
|
|
143
|
-
({ dispatch, store }) => {
|
|
144
|
-
const visible = store[selectVisible]();
|
|
145
|
-
if (visible) {
|
|
146
|
-
store[doRemoveLayer]();
|
|
147
|
-
} else {
|
|
148
|
-
store[doAddLayer]();
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
[doAddInteractions]:
|
|
153
|
-
() =>
|
|
154
|
-
({ dispatch, store }) => {
|
|
155
|
-
store.doSetCursor("crosshair");
|
|
156
|
-
const map = store.selectMap();
|
|
157
|
-
const interactions = store[selectInteractions]();
|
|
158
|
-
interactions.forEach((interaction) => {
|
|
159
|
-
map.addInteraction(interaction);
|
|
160
|
-
});
|
|
161
|
-
dispatch({
|
|
162
|
-
type: actions.ACTIVATE,
|
|
163
|
-
payload: {
|
|
164
|
-
active: true,
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
[doRemoveInteractions]:
|
|
170
|
-
() =>
|
|
171
|
-
({ dispatch, store }) => {
|
|
172
|
-
store.doSetCursor();
|
|
173
|
-
const map = store.selectMap();
|
|
174
|
-
const interactions = store[selectInteractions]();
|
|
175
|
-
interactions.forEach((interaction) => {
|
|
176
|
-
map.removeInteraction(interaction);
|
|
177
|
-
});
|
|
178
|
-
dispatch({
|
|
179
|
-
type: actions.DEACTIVATE,
|
|
180
|
-
payload: {
|
|
181
|
-
active: false,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
[doToggleInteractions]:
|
|
187
|
-
() =>
|
|
188
|
-
({ store }) => {
|
|
189
|
-
const active = store.selectActive();
|
|
190
|
-
if (active) {
|
|
191
|
-
store[doRemoveInteractions]();
|
|
192
|
-
} else {
|
|
193
|
-
store[doAddInteractions]();
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
[selectActive]: (state) => {
|
|
198
|
-
return state[config.name].active;
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
[selectVisible]: (state) => {
|
|
202
|
-
return state[config.name].visible;
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
[selectLayer]: (state) => {
|
|
206
|
-
return state[config.name].layer;
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
[selectDrawInteraction]: (state) => {
|
|
210
|
-
return state[config.name].drawInteraction;
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
[selectInteractions]: createSelector(selectDrawInteraction, (draw) => {
|
|
214
|
-
return [draw];
|
|
215
|
-
}),
|
|
216
|
-
|
|
217
|
-
[reactShouldInitialize]: (state) => {
|
|
218
|
-
if (state[config.name].shouldInitialize)
|
|
219
|
-
return { actionCreator: doInitialize };
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { connect } from "../../utils/redux-bundler-react";
|
|
3
|
-
import {
|
|
4
|
-
BasicToolbarButton,
|
|
5
|
-
BasicToolbarMenu,
|
|
6
|
-
BasicToolbarMenuItem,
|
|
7
|
-
BasicToolbarMenuDivider,
|
|
8
|
-
BasicToolbarSubmenu,
|
|
9
|
-
} from "../../application-controls";
|
|
10
|
-
import DrawToolItem from "./draw-tool-item";
|
|
11
|
-
|
|
12
|
-
class DrawButton extends React.Component {
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
this.state = {
|
|
16
|
-
mode: null,
|
|
17
|
-
};
|
|
18
|
-
this.updateMode = this.updateMode.bind(this);
|
|
19
|
-
this.handleDeactivate = this.handleDeactivate.bind(this);
|
|
20
|
-
this.removeInteractions = this.removeInteractions.bind(this);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
handleDeactivate() {
|
|
24
|
-
this.setState(
|
|
25
|
-
{
|
|
26
|
-
mode: null,
|
|
27
|
-
},
|
|
28
|
-
this.removeInteractions
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
addInteractions() {
|
|
33
|
-
this.removeInteractions();
|
|
34
|
-
const {
|
|
35
|
-
doDrawPointsAddInteractions,
|
|
36
|
-
doDrawLinesAddInteractions,
|
|
37
|
-
doDrawPolygonsAddInteractions,
|
|
38
|
-
doDrawLabelsAddInteractions,
|
|
39
|
-
doDrawModifyAddInteractions,
|
|
40
|
-
} = this.props;
|
|
41
|
-
const { mode } = this.state;
|
|
42
|
-
switch (mode) {
|
|
43
|
-
case "Point":
|
|
44
|
-
return doDrawPointsAddInteractions();
|
|
45
|
-
case "LineString":
|
|
46
|
-
return doDrawLinesAddInteractions();
|
|
47
|
-
case "Polygon":
|
|
48
|
-
return doDrawPolygonsAddInteractions();
|
|
49
|
-
case "Labels":
|
|
50
|
-
return doDrawLabelsAddInteractions();
|
|
51
|
-
case "Modify":
|
|
52
|
-
return doDrawModifyAddInteractions();
|
|
53
|
-
default:
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
removeInteractions() {
|
|
59
|
-
const {
|
|
60
|
-
doDrawPointsRemoveInteractions,
|
|
61
|
-
doDrawLinesRemoveInteractions,
|
|
62
|
-
doDrawPolygonsRemoveInteractions,
|
|
63
|
-
doDrawLabelsRemoveInteractions,
|
|
64
|
-
doDrawModifyRemoveInteractions,
|
|
65
|
-
} = this.props;
|
|
66
|
-
doDrawPointsRemoveInteractions();
|
|
67
|
-
doDrawLinesRemoveInteractions();
|
|
68
|
-
doDrawPolygonsRemoveInteractions();
|
|
69
|
-
doDrawLabelsRemoveInteractions();
|
|
70
|
-
doDrawModifyRemoveInteractions();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
updateMode(e) {
|
|
74
|
-
const mode = e.currentTarget.dataset.mode;
|
|
75
|
-
this.setState(
|
|
76
|
-
{
|
|
77
|
-
mode: mode,
|
|
78
|
-
},
|
|
79
|
-
this.addInteractions
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
render() {
|
|
84
|
-
const {
|
|
85
|
-
drawPointsVisible,
|
|
86
|
-
drawPointsActive,
|
|
87
|
-
doDrawPointsToggleVisible,
|
|
88
|
-
|
|
89
|
-
drawLinesVisible,
|
|
90
|
-
drawLinesActive,
|
|
91
|
-
doDrawLinesToggleVisible,
|
|
92
|
-
|
|
93
|
-
drawPolygonsVisible,
|
|
94
|
-
drawPolygonsActive,
|
|
95
|
-
doDrawPolygonsToggleVisible,
|
|
96
|
-
|
|
97
|
-
drawLabelsActive,
|
|
98
|
-
drawModifyActive,
|
|
99
|
-
} = this.props;
|
|
100
|
-
return (
|
|
101
|
-
<BasicToolbarButton
|
|
102
|
-
enabled={true}
|
|
103
|
-
iconClass="mdi mdi-pencil"
|
|
104
|
-
title="Draw Tools"
|
|
105
|
-
onDeactivate={this.handleDeactivate}
|
|
106
|
-
>
|
|
107
|
-
<BasicToolbarMenu>
|
|
108
|
-
<BasicToolbarMenuItem
|
|
109
|
-
active={drawModifyActive}
|
|
110
|
-
iconClass="ms ms-draw icon-inline"
|
|
111
|
-
title="Modify Draw Features"
|
|
112
|
-
text="Modify Draw Features"
|
|
113
|
-
onClick={this.updateMode}
|
|
114
|
-
passProps={{ "data-mode": "Modify" }}
|
|
115
|
-
/>
|
|
116
|
-
<BasicToolbarMenuItem
|
|
117
|
-
active={drawLabelsActive}
|
|
118
|
-
iconClass="ms ms-label-o icon-inline"
|
|
119
|
-
title="Add / Edit Labels"
|
|
120
|
-
text="Add / Edit Labels"
|
|
121
|
-
onClick={this.updateMode}
|
|
122
|
-
passProps={{ "data-mode": "Labels" }}
|
|
123
|
-
/>
|
|
124
|
-
<BasicToolbarMenuDivider />
|
|
125
|
-
<DrawToolItem
|
|
126
|
-
active={drawPointsActive}
|
|
127
|
-
visible={drawPointsVisible}
|
|
128
|
-
iconClass="ms ms-draw-point icon-inline"
|
|
129
|
-
title="Draw Points"
|
|
130
|
-
text="Draw Points"
|
|
131
|
-
onClick={this.updateMode}
|
|
132
|
-
passProps={{ "data-mode": "Point" }}
|
|
133
|
-
onToggleVisibility={doDrawPointsToggleVisible}
|
|
134
|
-
/>
|
|
135
|
-
<DrawToolItem
|
|
136
|
-
active={drawLinesActive}
|
|
137
|
-
visible={drawLinesVisible}
|
|
138
|
-
iconClass="ms ms-draw-line icon-inline"
|
|
139
|
-
title="Draw Lines"
|
|
140
|
-
text="Draw Lines"
|
|
141
|
-
onClick={this.updateMode}
|
|
142
|
-
passProps={{ "data-mode": "LineString" }}
|
|
143
|
-
onToggleVisibility={doDrawLinesToggleVisible}
|
|
144
|
-
/>
|
|
145
|
-
<DrawToolItem
|
|
146
|
-
active={drawPolygonsActive}
|
|
147
|
-
visible={drawPolygonsVisible}
|
|
148
|
-
iconClass="ms ms-draw-polygon icon-inline"
|
|
149
|
-
title="Draw Polygons"
|
|
150
|
-
text="Draw Polygons"
|
|
151
|
-
onClick={this.updateMode}
|
|
152
|
-
passProps={{ "data-mode": "Polygon" }}
|
|
153
|
-
onToggleVisibility={doDrawPolygonsToggleVisible}
|
|
154
|
-
/>
|
|
155
|
-
</BasicToolbarMenu>
|
|
156
|
-
</BasicToolbarButton>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export default connect(
|
|
162
|
-
"selectDrawPointsVisible",
|
|
163
|
-
"selectDrawPointsActive",
|
|
164
|
-
"doDrawPointsToggleVisible",
|
|
165
|
-
"doDrawPointsAddInteractions",
|
|
166
|
-
"doDrawPointsRemoveInteractions",
|
|
167
|
-
|
|
168
|
-
"selectDrawLinesVisible",
|
|
169
|
-
"selectDrawLinesActive",
|
|
170
|
-
"doDrawLinesToggleVisible",
|
|
171
|
-
"doDrawLinesAddInteractions",
|
|
172
|
-
"doDrawLinesRemoveInteractions",
|
|
173
|
-
|
|
174
|
-
"selectDrawPolygonsVisible",
|
|
175
|
-
"selectDrawPolygonsActive",
|
|
176
|
-
"doDrawPolygonsToggleVisible",
|
|
177
|
-
"doDrawPolygonsAddInteractions",
|
|
178
|
-
"doDrawPolygonsRemoveInteractions",
|
|
179
|
-
|
|
180
|
-
"selectDrawLabelsActive",
|
|
181
|
-
"doDrawLabelsAddInteractions",
|
|
182
|
-
"doDrawLabelsRemoveInteractions",
|
|
183
|
-
|
|
184
|
-
"selectDrawModifyActive",
|
|
185
|
-
"doDrawModifyAddInteractions",
|
|
186
|
-
"doDrawModifyRemoveInteractions",
|
|
187
|
-
|
|
188
|
-
DrawButton
|
|
189
|
-
);
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import Select from 'ol/interaction/Select';
|
|
2
|
-
import { createSelector } from 'redux-bundler';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'drawLabels',
|
|
6
|
-
|
|
7
|
-
getReducer: () => {
|
|
8
|
-
const initialData = {
|
|
9
|
-
active: false,
|
|
10
|
-
select: null,
|
|
11
|
-
shouldInitialize: false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return (state = initialData, { type, payload }) => {
|
|
15
|
-
if(type.indexOf('DRAW') !== -1) console.log(type)
|
|
16
|
-
switch(type){
|
|
17
|
-
case 'DRAW_LABELS_INITIALIZE_START':
|
|
18
|
-
case 'DRAW_LABELS_INITIALIZE_FINISH':
|
|
19
|
-
case 'DRAW_LABELS_ACTIVATE':
|
|
20
|
-
case 'DRAW_LABELS_DEACTIVATE':
|
|
21
|
-
return Object.assign({}, state, payload);
|
|
22
|
-
case 'DRAWPOINTS_INITIALIZE_FINISH':
|
|
23
|
-
case 'DRAWLINES_INITIALIZE_FINISH':
|
|
24
|
-
case 'DRAWPOLYGONS_INITIALIZE_FINISH':
|
|
25
|
-
return Object.assign({}, state, {
|
|
26
|
-
shouldInitialize: true
|
|
27
|
-
})
|
|
28
|
-
default:
|
|
29
|
-
return state;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
doDrawLabelsInitialize: () => ({ dispatch, store }) => {
|
|
35
|
-
dispatch({
|
|
36
|
-
type: 'DRAW_LABELS_INITIALIZE_START',
|
|
37
|
-
payload: {
|
|
38
|
-
shouldInitialize: false
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const layers = store.selectDrawLabelsChildLayers();
|
|
43
|
-
if(!layers) return null;
|
|
44
|
-
|
|
45
|
-
const select = new Select({
|
|
46
|
-
layers: layers
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
select.on('select', store.doDrawLabelsHandleSelect);
|
|
50
|
-
|
|
51
|
-
dispatch({
|
|
52
|
-
type: 'DRAW_LABELS_INITIALIZE_FINISH',
|
|
53
|
-
payload: {
|
|
54
|
-
select: select
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
doDrawLabelsAddInteractions: () => ({ dispatch, store }) => {
|
|
60
|
-
store.doSetCursor('pointer');
|
|
61
|
-
const map = store.selectMap();
|
|
62
|
-
const select = store.selectDrawLabelsInteraction();
|
|
63
|
-
map.addInteraction(select);
|
|
64
|
-
dispatch({
|
|
65
|
-
type: 'DRAW_LABELS_ACTIVATE',
|
|
66
|
-
payload: {
|
|
67
|
-
active: true
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
doDrawLabelsRemoveInteractions: () => ({ dispatch, store }) => {
|
|
73
|
-
store.doSetCursor();
|
|
74
|
-
const map = store.selectMap();
|
|
75
|
-
const select = store.selectDrawLabelsInteraction();
|
|
76
|
-
map.removeInteraction(select);
|
|
77
|
-
dispatch({
|
|
78
|
-
type: 'DRAW_LABELS_DEACTIVATE',
|
|
79
|
-
payload: {
|
|
80
|
-
active: false
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
doDrawLabelsHandleSelect: (e) => ({ store }) => {
|
|
86
|
-
const feature = e.selected[0];
|
|
87
|
-
const label = feature.get('label') || '';
|
|
88
|
-
const newLabel = window.prompt('Label the Draw Feature', label);
|
|
89
|
-
feature.set('label', newLabel);
|
|
90
|
-
const select = store.selectDrawLabelsInteraction();
|
|
91
|
-
const features = select.getFeatures();
|
|
92
|
-
features.clear();
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
selectDrawLabelsChildLayers: createSelector(
|
|
96
|
-
'selectDrawPointsLayer',
|
|
97
|
-
'selectDrawLinesLayer',
|
|
98
|
-
'selectDrawPolygonsLayer',
|
|
99
|
-
(points, lines, polygons) => {
|
|
100
|
-
if(!points || !lines || !polygons) return null;
|
|
101
|
-
return [points, lines, polygons];
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
|
-
|
|
105
|
-
selectDrawLabelsActive: (state) => {
|
|
106
|
-
return state.drawLabels.active;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
selectDrawLabelsInteraction: (state) => {
|
|
110
|
-
return state.drawLabels.select;
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
reactDrawLabelsShouldInitialize: (state) => {
|
|
114
|
-
if(state.drawLabels.shouldInitialize) return { actionCreator: 'doDrawLabelsInitialize' }
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import Select from 'ol/interaction/Select';
|
|
2
|
-
import Modify from 'ol/interaction/Modify';
|
|
3
|
-
import { createSelector } from 'redux-bundler';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'drawModify',
|
|
7
|
-
|
|
8
|
-
getReducer: () => {
|
|
9
|
-
const initialData = {
|
|
10
|
-
active: false,
|
|
11
|
-
select: null,
|
|
12
|
-
modify: null,
|
|
13
|
-
shouldInitialize: false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (state = initialData, { type, payload }) => {
|
|
17
|
-
switch(type){
|
|
18
|
-
case 'DRAW_MODIFY_INITIALIZE_START':
|
|
19
|
-
case 'DRAW_MODIFY_INITIALIZE_FINISH':
|
|
20
|
-
case 'DRAW_MODIFY_ACTIVATE':
|
|
21
|
-
case 'DRAW_MODIFY_DEACTIVATE':
|
|
22
|
-
return Object.assign({}, state, payload);
|
|
23
|
-
case 'DRAWPOINTS_INITIALIZE_FINISH':
|
|
24
|
-
case 'DRAWLINES_INITIALIZE_FINISH':
|
|
25
|
-
case 'DRAWPOLYGONS_INITIALIZE_FINISH':
|
|
26
|
-
return Object.assign({}, state, {
|
|
27
|
-
shouldInitialize: true
|
|
28
|
-
})
|
|
29
|
-
default:
|
|
30
|
-
return state;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
doDrawModifyInitialize: () => ({ dispatch, store }) => {
|
|
36
|
-
dispatch({
|
|
37
|
-
type: 'DRAW_MODIFY_INITIALIZE_START',
|
|
38
|
-
payload: {
|
|
39
|
-
shouldInitialize: false
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
const layers = store.selectDrawModifyChildLayers();
|
|
44
|
-
if(!layers) return null;
|
|
45
|
-
|
|
46
|
-
const select = new Select({
|
|
47
|
-
layers: layers
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const modify = new Modify({
|
|
51
|
-
features: select.getFeatures()
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
dispatch({
|
|
55
|
-
type: 'DRAW_MODIFY_INITIALIZE_FINISH',
|
|
56
|
-
payload: {
|
|
57
|
-
select: select,
|
|
58
|
-
modify: modify
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
doDrawModifyAddInteractions: () => ({ dispatch, store }) => {
|
|
64
|
-
store.doSetCursor('pointer');
|
|
65
|
-
const map = store.selectMap();
|
|
66
|
-
const interactions = store.selectDrawModifyInteraction();
|
|
67
|
-
interactions.forEach((interaction) => {
|
|
68
|
-
map.addInteraction(interaction);
|
|
69
|
-
})
|
|
70
|
-
window.addEventListener('keyup', store.doDrawModifyHandleKeyUp);
|
|
71
|
-
dispatch({
|
|
72
|
-
type: 'DRAW_MODIFY_ACTIVATE',
|
|
73
|
-
payload: {
|
|
74
|
-
active: true
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
doDrawModifyRemoveInteractions: () => ({ dispatch, store }) => {
|
|
80
|
-
store.doSetCursor();
|
|
81
|
-
const map = store.selectMap();
|
|
82
|
-
const interactions = store.selectDrawModifyInteraction();
|
|
83
|
-
interactions.forEach((interaction) => {
|
|
84
|
-
map.removeInteraction(interaction);
|
|
85
|
-
})
|
|
86
|
-
window.removeEventListener('keyup', store.doDrawModifyHandleKeyUp);
|
|
87
|
-
dispatch({
|
|
88
|
-
type: 'DRAW_MODIFY_DEACTIVATE',
|
|
89
|
-
payload: {
|
|
90
|
-
active: false
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
doDrawModifyHandleSelect: (e) => ({ store }) => {
|
|
96
|
-
const feature = e.selected[0];
|
|
97
|
-
const label = feature.get('label') || '';
|
|
98
|
-
const newLabel = window.prompt('Label the Draw Feature', label);
|
|
99
|
-
feature.set('label', newLabel);
|
|
100
|
-
const select = store.selectDrawModifyInteraction();
|
|
101
|
-
const features = select.getFeatures();
|
|
102
|
-
features.clear();
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
doDrawModifyHandleKeyUp: (e) => ({ store }) => {
|
|
106
|
-
const keyCode = e.keyCode;
|
|
107
|
-
const select = store.selectDrawModifySelect();
|
|
108
|
-
const features = select.getFeatures();
|
|
109
|
-
const layers = store.selectDrawModifyChildLayers();
|
|
110
|
-
if(!layers) return null;
|
|
111
|
-
// check for delete or backspace
|
|
112
|
-
if([8, 46].indexOf(keyCode) !== -1){
|
|
113
|
-
features.forEach((f) => {
|
|
114
|
-
layers.forEach((l) => {
|
|
115
|
-
const src = l.getSource();
|
|
116
|
-
src.removeFeature(f);
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
features.clear();
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
selectDrawModifyChildLayers: createSelector(
|
|
124
|
-
'selectDrawPointsLayer',
|
|
125
|
-
'selectDrawLinesLayer',
|
|
126
|
-
'selectDrawPolygonsLayer',
|
|
127
|
-
(points, lines, polygons) => {
|
|
128
|
-
if(!points || !lines || !polygons) return null;
|
|
129
|
-
return [points, lines, polygons];
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
|
|
133
|
-
selectDrawModifyActive: (state) => {
|
|
134
|
-
return state.drawModify.active;
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
selectDrawModifySelect: (state) => {
|
|
138
|
-
return state.drawModify.select;
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
selectDrawModifyModify: (state) => {
|
|
142
|
-
return state.drawModify.modify;
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
selectDrawModifyInteraction: createSelector(
|
|
146
|
-
'selectDrawModifySelect',
|
|
147
|
-
'selectDrawModifyModify',
|
|
148
|
-
(select, modify) => {
|
|
149
|
-
return [select, modify]
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
|
|
153
|
-
reactDrawModifyShouldInitialize: (state) => {
|
|
154
|
-
if(state.drawModify.shouldInitialize) return { actionCreator: 'doDrawModifyInitialize' }
|
|
155
|
-
}
|
|
156
|
-
}
|