@corpsmap/corpsmap 3.2.81 → 3.2.83

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.
@@ -44,209 +44,186 @@ export default {
44
44
  }
45
45
  };
46
46
  },
47
- doCoordsInitialize:
48
- () =>
49
- ({ dispatch, store }) => {
50
- dispatch({
51
- type: "COORD_INITIALIZE_START",
52
- payload: {
53
- _shouldInitialize: false,
54
- },
55
- });
56
-
57
- const map = store.selectMap();
58
- map.on("pointermove", throttle(store.doCoordsPointerMove, 200));
59
-
60
- dispatch({
61
- type: "COORD_INITIALIZE_FINISH",
62
- });
63
- },
64
- doCoordsPointerMove:
65
- (e) =>
66
- ({ dispatch, store }) => {
67
- e.preventDefault();
68
- e.stopPropagation();
47
+ doCoordsInitialize: () => ({ dispatch, store }) => {
48
+ dispatch({
49
+ type: "COORD_INITIALIZE_START",
50
+ payload: {
51
+ _shouldInitialize: false,
52
+ },
53
+ });
69
54
 
70
- const displayProjection = store.selectDisplayProjection();
71
- const coord = e.coordinate;
72
- const projected = transform(coord, "EPSG:3857", displayProjection);
73
- const X = Math.round(projected[0] * 10000) / 10000;
74
- const Y = Math.round(projected[1] * 10000) / 10000;
55
+ const map = store.selectMap();
56
+ map.on("pointermove", throttle(store.doCoordsPointerMove, 200));
75
57
 
76
- dispatch({
77
- type: "COORD_POSITION_UPDATE",
78
- payload: {
79
- values: { X, Y },
58
+ dispatch({
59
+ type: "COORD_INITIALIZE_FINISH",
60
+ });
61
+ },
62
+ doCoordsPointerMove: (e) => ({ dispatch, store }) => {
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+
66
+ const displayProjection = store.selectDisplayProjection();
67
+ const coord = e.coordinate;
68
+ const projected = transform(coord, "EPSG:3857", displayProjection);
69
+ const X = Math.round(projected[0] * 10000) / 10000;
70
+ const Y = Math.round(projected[1] * 10000) / 10000;
71
+
72
+ dispatch({
73
+ type: "COORD_POSITION_UPDATE",
74
+ payload: {
75
+ values: { X, Y },
76
+ },
77
+ });
78
+ },
79
+ doRenderCoordsOverlay: (center, coords) => ({ dispatch, store }) => {
80
+ const map = store.selectMap();
81
+ const hasCoordsOverlay = store.selectCoordsOverlay();
82
+
83
+ if (hasCoordsOverlay) {
84
+ store.doClearCoordOverlay(hasCoordsOverlay);
85
+ }
86
+ //generate overlay
87
+ const el = document.createElement("div");
88
+ const overlay = new Overlay({
89
+ element: el,
90
+ positioning: "bottom-center",
91
+ offset: [0, -10],
92
+ });
93
+
94
+ //add overlay to map
95
+ map.addOverlay(overlay);
96
+ ReactDOM.render(
97
+ <Popup
98
+ overlay={overlay}
99
+ coords={coords}
100
+ map={map}
101
+ onClear={store.doClearPopup}
102
+ />,
103
+ el
104
+ );
105
+
106
+ overlay.setPosition(center);
107
+ dispatch({ type: "COORD_OVERLAY_RENDERED", payload: { overlay: overlay } });
108
+ },
109
+ doClearPopup: (e, overlay) => ({ store }) => {
110
+ console.log(e);
111
+ e.preventDefault();
112
+ e.stopPropagation();
113
+ store.doClearCoordOverlay(overlay);
114
+ },
115
+ doClearCoordOverlay: (overlay) => ({ dispatch, store }) => {
116
+ const map = store.selectMap();
117
+ overlay.setPosition(undefined);
118
+ const el = overlay.getElement();
119
+ el.parentNode.removeChild(el);
120
+ map.removeOverlay(overlay);
121
+ dispatch({ type: "COORD_OVERLAY_REMOVED", payload: { overlay: null } });
122
+ },
123
+ doStartCoordCopy: () => ({ dispatch, store }) => {
124
+ const map = store.selectMap();
125
+ store.doSetCursor("crosshair");
126
+
127
+ //Parent container for coord copy.
128
+ const container = document.createElement("div");
129
+ container.id = "cm-copy-coords";
130
+ document.body.appendChild(container);
131
+
132
+ dispatch({
133
+ type: "COORD_COPY_ACTIVE",
134
+ payload: {
135
+ copyActive: true,
136
+ container: container,
137
+ notification: {
138
+ message: "Click on map to copy coordinates.",
139
+ level: "info",
80
140
  },
81
- });
82
- },
83
- doRenderCoordsOverlay:
84
- (center, coords) =>
85
- ({ dispatch, store }) => {
86
- const map = store.selectMap();
87
- const hasCoordsOverlay = store.selectCoordsOverlay();
88
-
89
- if (hasCoordsOverlay) {
90
- store.doClearCoordOverlay(hasCoordsOverlay);
91
- }
92
- //generate overlay
93
- const el = document.createElement("div");
94
- const overlay = new Overlay({
95
- element: el,
96
- positioning: "bottom-center",
97
- offset: [0, -10],
98
- });
99
-
100
- //add overlay to map
101
- map.addOverlay(overlay);
102
- ReactDOM.render(
103
- <Popup
104
- overlay={overlay}
105
- coords={coords}
106
- map={map}
107
- onClear={store.doClearPopup}
108
- />,
109
- el
110
- );
111
-
112
- overlay.setPosition(center);
113
- dispatch({
114
- type: "COORD_OVERLAY_RENDERED",
115
- payload: { overlay: overlay },
116
- });
117
- },
118
- doClearPopup:
119
- (e, overlay) =>
120
- ({ store }) => {
121
- console.log(e);
122
- e.preventDefault();
123
- e.stopPropagation();
124
- store.doClearCoordOverlay(overlay);
125
- },
126
- doClearCoordOverlay:
127
- (overlay) =>
128
- ({ dispatch, store }) => {
129
- const map = store.selectMap();
130
- overlay.setPosition(undefined);
131
- const el = overlay.getElement();
132
- el.parentNode.removeChild(el);
133
- map.removeOverlay(overlay);
134
- dispatch({ type: "COORD_OVERLAY_REMOVED", payload: { overlay: null } });
135
- },
136
- doStartCoordCopy:
137
- () =>
138
- ({ dispatch, store }) => {
139
- const map = store.selectMap();
140
- store.doSetCursor("crosshair");
141
-
142
- //Parent container for coord copy.
143
- const container = document.createElement("div");
144
- container.id = "cm-copy-coords";
145
- document.body.appendChild(container);
141
+ },
142
+ });
146
143
 
147
- dispatch({
148
- type: "COORD_COPY_ACTIVE",
149
- payload: {
150
- copyActive: true,
151
- container: container,
152
- notification: {
153
- message: "Click on map to copy coordinates.",
154
- level: "info",
155
- },
144
+ //listen once for click event
145
+ map.once("singleclick", store.doCoordCopy);
146
+ },
147
+ doCoordCopy: (e) => ({ dispatch, store }) => {
148
+ e.preventDefault();
149
+ e.stopPropagation();
150
+
151
+ const copyContainer = store.selectCoordsContainer();
152
+ const displayProjection = store.selectDisplayProjection();
153
+ const coord = e.coordinate;
154
+ const projected = transform(coord, "EPSG:3857", displayProjection);
155
+ const x = Math.round(projected[0] * 10000) / 10000;
156
+ const y = Math.round(projected[1] * 10000) / 10000;
157
+
158
+ //Add temp input node to use execCommand.
159
+ const valueEl = document.createElement("input");
160
+ copyContainer.appendChild(valueEl);
161
+ valueEl.value = `${x}, ${y}`;
162
+ valueEl.select();
163
+ document.execCommand("copy");
164
+
165
+ store.doStopCoordCopy(x, y);
166
+ },
167
+ doStopCoordCopy: (x, y) => ({ dispatch, store }) => {
168
+ const copyContainer = store.selectCoordsContainer();
169
+ const msg = `Copied ${x}, ${y} to the clipboard.`;
170
+ store.doSetCursor("default");
171
+
172
+ dispatch({
173
+ type: "COORD_COPIED",
174
+ payload: {
175
+ copyActive: false,
176
+ container: null,
177
+ notification: {
178
+ title: "Coordinate Display",
179
+ message: msg,
180
+ level: "info",
156
181
  },
157
- });
158
-
159
- //listen once for click event
160
- map.once("singleclick", store.doCoordCopy);
161
- },
162
- doCoordCopy:
163
- (e) =>
164
- ({ dispatch, store }) => {
165
- e.preventDefault();
166
- e.stopPropagation();
167
-
168
- const copyContainer = store.selectCoordsContainer();
169
- const displayProjection = store.selectDisplayProjection();
170
- const coord = e.coordinate;
171
- const projected = transform(coord, "EPSG:3857", displayProjection);
172
- const x = Math.round(projected[0] * 10000) / 10000;
173
- const y = Math.round(projected[1] * 10000) / 10000;
174
-
175
- //Add temp input node to use execCommand.
176
- const valueEl = document.createElement("input");
177
- copyContainer.appendChild(valueEl);
178
- valueEl.value = `${x}, ${y}`;
179
- valueEl.select();
180
- document.execCommand("copy");
182
+ },
183
+ });
181
184
 
182
- store.doStopCoordCopy(x, y);
183
- },
184
- doStopCoordCopy:
185
- (x, y) =>
186
- ({ dispatch, store }) => {
187
- const copyContainer = store.selectCoordsContainer();
188
- const msg = `Copied ${x}, ${y} to the clipboard.`;
189
- store.doSetCursor("default");
185
+ copyContainer.remove(); //remove dynamically created node.
186
+ store.doBasicToolbarDeactivate(); //close tool after copy.
187
+ },
188
+ doUpdateCoordInput: (e, label) => ({ dispatch, store }) => {
189
+ e.preventDefault();
190
+ e.stopPropagation();
191
+ const latLonInput = store.selectCoordsLatLonInput();
192
+
193
+ dispatch({
194
+ type: "COORD_INPUT_UPDATED",
195
+ payload: {
196
+ latLonInput: {
197
+ ...latLonInput,
198
+ [`${label}`]: e.currentTarget.value,
199
+ },
200
+ },
201
+ });
202
+ },
203
+ doCoordZoomTo: () => ({ dispatch, store }) => {
204
+ const latLonInput = store.selectCoordsLatLonInput();
205
+ const displayProjection = store.selectDisplayProjection();
206
+ const x = Number(latLonInput.X);
207
+ const y = Number(latLonInput.Y);
190
208
 
209
+ if (isNaN(x) || isNaN(y)) {
191
210
  dispatch({
192
- type: "COORD_COPIED",
211
+ type: "COORD_INPUT_INVALID",
193
212
  payload: {
194
- copyActive: false,
195
- container: null,
196
213
  notification: {
197
214
  title: "Coordinate Display",
198
- message: msg,
199
- level: "info",
215
+ message: "Enter valid number.",
216
+ level: "danger",
200
217
  },
201
218
  },
202
219
  });
203
-
204
- copyContainer.remove(); //remove dynamically created node.
205
- store.doBasicToolbarDeactivate(); //close tool after copy.
206
- },
207
- doUpdateCoordInput:
208
- (e, label) =>
209
- ({ dispatch, store }) => {
210
- e.preventDefault();
211
- e.stopPropagation();
212
- const latLonInput = store.selectCoordsLatLonInput();
213
-
214
- dispatch({
215
- type: "COORD_INPUT_UPDATED",
216
- payload: {
217
- latLonInput: {
218
- ...latLonInput,
219
- [`${label}`]: e.currentTarget.value,
220
- },
221
- },
222
- });
223
- },
224
- doCoordZoomTo:
225
- () =>
226
- ({ dispatch, store }) => {
227
- const latLonInput = store.selectCoordsLatLonInput();
228
- const displayProjection = store.selectDisplayProjection();
229
- const x = Number(latLonInput.X);
230
- const y = Number(latLonInput.Y);
231
-
232
- if (isNaN(x) || isNaN(y)) {
233
- dispatch({
234
- type: "COORD_INPUT_INVALID",
235
- payload: {
236
- notification: {
237
- title: "Coordinate Display",
238
- message: "Enter valid number.",
239
- level: "danger",
240
- },
241
- },
242
- });
243
- } else {
244
- const center = transform([x, y], displayProjection, "EPSG:3857");
245
- store.doRenderCoordsOverlay(center, { x, y });
246
- store.doZoomToLocation(center, 13);
247
- store.doBasicToolbarDeactivate();
248
- }
249
- },
220
+ } else {
221
+ const center = transform([x, y], displayProjection, "EPSG:3857");
222
+ store.doRenderCoordsOverlay(center, { x, y });
223
+ store.doZoomToLocation(center, 13);
224
+ store.doBasicToolbarDeactivate();
225
+ }
226
+ },
250
227
  selectCoordsValues: (state) => {
251
228
  return state.coordinateDisplay.values;
252
229
  },