@corpsmap/corpsmap 3.2.74 → 3.2.77
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/.babelrc +10 -2
- package/css/corpsmap.css +9688 -9688
- package/lib/assets/index-42a6cd56.css +10185 -0
- package/lib/dev.js +89835 -83467
- package/lib/prod.js +88514 -83465
- package/package.json +34 -27
- package/rollup.config.js +23 -21
- package/src/application-bundles/api-bundle.js +34 -32
- package/src/core-plugins/add-data/bundle.js +1 -1
- package/src/core-plugins/coordinate-display/bundle.js +189 -166
- package/src/core-plugins/basemap-switcher/basemap-switcher-list-item copy.js +0 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corpsmap/corpsmap",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.77",
|
|
4
4
|
"description": "CorpsMap as React Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,37 +16,44 @@
|
|
|
16
16
|
"author": "willbreitkreutz",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/
|
|
20
|
-
"@babel/
|
|
21
|
-
"@babel/
|
|
22
|
-
"@babel/
|
|
23
|
-
"babel
|
|
19
|
+
"@babel/cli": "^7.28.3",
|
|
20
|
+
"@babel/core": "^7.28.5",
|
|
21
|
+
"@babel/eslint-parser": "^7.26.10",
|
|
22
|
+
"@babel/plugin-transform-class-properties": "^7.27.1",
|
|
23
|
+
"@babel/plugin-transform-numeric-separator": "^7.27.1",
|
|
24
|
+
"@babel/preset-env": "^7.28.5",
|
|
25
|
+
"@babel/preset-react": "^7.28.5",
|
|
26
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
27
|
+
"@rollup/plugin-commonjs": "^28.0.9",
|
|
28
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
30
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
32
|
+
"babel-loader": "^10.0.0",
|
|
33
|
+
"babel-plugin-import": "^1.13.8",
|
|
24
34
|
"concurrently": "^5.3.0",
|
|
25
35
|
"cross-env": "^5.2.0",
|
|
26
|
-
"
|
|
27
|
-
"react
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"rollup
|
|
31
|
-
"rollup-plugin-css-only": "^
|
|
32
|
-
"rollup-plugin-json": "^4.0.0",
|
|
33
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
36
|
+
"glob": "^9.0.0",
|
|
37
|
+
"react": "^18.3.0",
|
|
38
|
+
"react-dom": "^18.3.0",
|
|
39
|
+
"react-select": "^5.10.2",
|
|
40
|
+
"rollup": "^2.68.0",
|
|
41
|
+
"rollup-plugin-css-only": "^4.5.2",
|
|
34
42
|
"rollup-plugin-postcss": "^2.0.3",
|
|
35
|
-
"
|
|
36
|
-
"styled-jsx": "^3.2.1",
|
|
43
|
+
"styled-jsx": "^5.1.6",
|
|
37
44
|
"wait-on": "^5.2.1"
|
|
38
45
|
},
|
|
39
46
|
"peerDependencies": {
|
|
40
|
-
"react": ">=
|
|
41
|
-
"react-dom": ">=
|
|
47
|
+
"react": ">= 18.x.x",
|
|
48
|
+
"react-dom": ">=18.x.x"
|
|
42
49
|
},
|
|
43
50
|
"dependencies": {
|
|
44
51
|
"@mapbox/togeojson": "^0.16.0",
|
|
45
|
-
"@turf/bbox": "^
|
|
46
|
-
"@turf/bbox-polygon": "^
|
|
47
|
-
"@turf/boolean-crosses": "^
|
|
48
|
-
"@turf/boolean-disjoint": "^
|
|
49
|
-
"@turf/boolean-point-in-polygon": "^
|
|
52
|
+
"@turf/bbox": "^7.2.0",
|
|
53
|
+
"@turf/bbox-polygon": "^7.2.0",
|
|
54
|
+
"@turf/boolean-crosses": "^7.2.0",
|
|
55
|
+
"@turf/boolean-disjoint": "^7.2.0",
|
|
56
|
+
"@turf/boolean-point-in-polygon": "^7.2.0",
|
|
50
57
|
"@turf/buffer": "^5.1.5",
|
|
51
58
|
"@turf/center-of-mass": "^6.0.1",
|
|
52
59
|
"@turf/centroid": "^6.0.2",
|
|
@@ -72,16 +79,16 @@
|
|
|
72
79
|
"ol-esri-style": "^2.0.7",
|
|
73
80
|
"parse2-kmz": "^1.0.5",
|
|
74
81
|
"proj4": "^2.4.4",
|
|
75
|
-
"react-data-grid": "
|
|
76
|
-
"react-datepicker": "^
|
|
82
|
+
"react-data-grid": "7.0.0-beta.42",
|
|
83
|
+
"react-datepicker": "^6.9.0",
|
|
84
|
+
"react-select": "^5.10.2",
|
|
77
85
|
"react-dnd": "^9.4.0",
|
|
78
86
|
"react-dnd-html5-backend": "^9.4.0",
|
|
79
|
-
"react-notification-system": "^0.2.17",
|
|
80
87
|
"react-split": "^2.0.7",
|
|
81
88
|
"redux-bundler": "^26.0.0",
|
|
82
89
|
"redux-bundler-react": "^1.2.0",
|
|
83
90
|
"shpjs": "^3.4.3",
|
|
84
|
-
"uuid": "^
|
|
91
|
+
"uuid": "^7.0.0",
|
|
85
92
|
"xhr": "^2.5.0"
|
|
86
93
|
}
|
|
87
94
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import babel from "rollup
|
|
2
|
-
import commonjs from "rollup
|
|
3
|
-
import resolve from "rollup
|
|
4
|
-
import replace from "rollup
|
|
1
|
+
import babel from "@rollup/plugin-babel";
|
|
2
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
3
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
4
|
+
import replace from "@rollup/plugin-replace";
|
|
5
5
|
import css from "rollup-plugin-css-only";
|
|
6
|
-
import postcss from
|
|
7
|
-
import json from
|
|
8
|
-
import pkg from
|
|
9
|
-
|
|
6
|
+
import postcss from "rollup-plugin-postcss";
|
|
7
|
+
import json from "@rollup/plugin-json";
|
|
8
|
+
import pkg from "./package.json";
|
|
9
|
+
import path from "path";
|
|
10
10
|
|
|
11
11
|
const NODE_ENV = process.env.NODE_ENV || "development";
|
|
12
12
|
const outputFile = NODE_ENV === "production" ? "./lib/prod.js" : "./lib/dev.js";
|
|
@@ -15,36 +15,38 @@ export default {
|
|
|
15
15
|
input: "./src/index.js",
|
|
16
16
|
output: {
|
|
17
17
|
file: outputFile,
|
|
18
|
-
format: "cjs"
|
|
18
|
+
format: "cjs",
|
|
19
19
|
},
|
|
20
20
|
plugins: [
|
|
21
21
|
replace({
|
|
22
|
-
"process.env.NODE_ENV": JSON.stringify(NODE_ENV)
|
|
22
|
+
"process.env.NODE_ENV": JSON.stringify(NODE_ENV),
|
|
23
23
|
}),
|
|
24
24
|
babel({
|
|
25
|
-
plugins:[[
|
|
26
|
-
extensions: [
|
|
27
|
-
exclude: "node_modules/**"
|
|
25
|
+
plugins: [["import", { libraryName: "antd", style: true }]],
|
|
26
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
27
|
+
exclude: "node_modules/**",
|
|
28
|
+
babelHelpers: "bundled",
|
|
28
29
|
}),
|
|
29
30
|
css({
|
|
30
|
-
output: "./css/corpsmap.css"
|
|
31
|
+
// output: "./css/corpsmap.css",
|
|
32
|
+
extract: path.resolve("./css/corpsmap.css"),
|
|
31
33
|
}),
|
|
32
34
|
resolve({
|
|
33
35
|
module: true,
|
|
34
36
|
jsnext: true,
|
|
35
37
|
customResolveOptions: {
|
|
36
|
-
moduleDirectory:
|
|
37
|
-
}
|
|
38
|
+
moduleDirectory: "node_modules",
|
|
39
|
+
},
|
|
38
40
|
}),
|
|
39
41
|
json(),
|
|
40
42
|
commonjs(),
|
|
41
43
|
postcss({
|
|
42
|
-
extensions: [
|
|
43
|
-
use: [
|
|
44
|
-
})
|
|
44
|
+
extensions: [".css", ".scss", ".less"],
|
|
45
|
+
use: ["sass", ["less", { javascriptEnabled: true }]],
|
|
46
|
+
}),
|
|
45
47
|
],
|
|
46
48
|
external: [
|
|
47
49
|
...Object.keys(pkg.devDependencies || {}),
|
|
48
|
-
...Object.keys(pkg.peerDependencies || {})
|
|
49
|
-
]
|
|
50
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
51
|
+
],
|
|
50
52
|
};
|
|
@@ -1,44 +1,46 @@
|
|
|
1
|
-
import xhr from
|
|
1
|
+
import xhr from "xhr";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
name:
|
|
4
|
+
name: "api",
|
|
5
5
|
|
|
6
6
|
getReducer: () => {
|
|
7
|
+
const root = `${process.env.REACT_APP_CM_ENV}`;
|
|
7
8
|
const initialData = {
|
|
8
|
-
root:
|
|
9
|
-
}
|
|
9
|
+
root: root === "undefined" ? "development" : root,
|
|
10
|
+
};
|
|
10
11
|
|
|
11
12
|
return (state = initialData, { type, payload }) => {
|
|
12
13
|
return state;
|
|
13
|
-
}
|
|
14
|
+
};
|
|
14
15
|
},
|
|
15
16
|
|
|
16
17
|
selectApiRoot: (state) => {
|
|
17
|
-
return process.env.NODE_ENV===
|
|
18
|
+
return process.env.NODE_ENV === "development"
|
|
19
|
+
? state.api.root
|
|
20
|
+
: state.windowLocation.origin;
|
|
18
21
|
},
|
|
19
22
|
|
|
20
23
|
getExtraArgs: (store) => {
|
|
21
|
-
|
|
22
24
|
return {
|
|
23
25
|
anonGet: (path, callback) => {
|
|
24
26
|
const options = {
|
|
25
|
-
url: path
|
|
26
|
-
}
|
|
27
|
-
xhr.get(options, callback)
|
|
27
|
+
url: path,
|
|
28
|
+
};
|
|
29
|
+
xhr.get(options, callback);
|
|
28
30
|
},
|
|
29
31
|
|
|
30
32
|
apiGet: (path, callback) => {
|
|
31
33
|
// const token = store.selectTokenRaw();
|
|
32
34
|
const token = null;
|
|
33
35
|
const options = {
|
|
34
|
-
url: path
|
|
35
|
-
}
|
|
36
|
-
if(token){
|
|
36
|
+
url: path,
|
|
37
|
+
};
|
|
38
|
+
if (token) {
|
|
37
39
|
options.headers = {
|
|
38
|
-
Authorization: "Bearer " + token
|
|
39
|
-
}
|
|
40
|
+
Authorization: "Bearer " + token,
|
|
41
|
+
};
|
|
40
42
|
}
|
|
41
|
-
xhr.get(options, callback)
|
|
43
|
+
xhr.get(options, callback);
|
|
42
44
|
},
|
|
43
45
|
|
|
44
46
|
apiPost: (path, payload, callback) => {
|
|
@@ -46,29 +48,29 @@ export default {
|
|
|
46
48
|
const token = null;
|
|
47
49
|
const options = {
|
|
48
50
|
url: path,
|
|
49
|
-
json: payload
|
|
50
|
-
}
|
|
51
|
-
if(token){
|
|
51
|
+
json: payload,
|
|
52
|
+
};
|
|
53
|
+
if (token) {
|
|
52
54
|
options.headers = {
|
|
53
|
-
Authorization: "Bearer " + token
|
|
54
|
-
}
|
|
55
|
+
Authorization: "Bearer " + token,
|
|
56
|
+
};
|
|
55
57
|
}
|
|
56
|
-
xhr.post(options, callback)
|
|
58
|
+
xhr.post(options, callback);
|
|
57
59
|
},
|
|
58
60
|
|
|
59
61
|
apiDel: (path, callback) => {
|
|
60
62
|
// const token = store.selectTokenRaw();
|
|
61
63
|
const token = null;
|
|
62
64
|
const options = {
|
|
63
|
-
url: path
|
|
64
|
-
}
|
|
65
|
-
if(token){
|
|
65
|
+
url: path,
|
|
66
|
+
};
|
|
67
|
+
if (token) {
|
|
66
68
|
options.headers = {
|
|
67
|
-
Authorization: "Bearer " + token
|
|
68
|
-
}
|
|
69
|
+
Authorization: "Bearer " + token,
|
|
70
|
+
};
|
|
69
71
|
}
|
|
70
|
-
xhr.del(options, callback)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
72
|
+
xhr.del(options, callback);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -44,186 +44,209 @@ export default {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
doCoordsInitialize:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
doCoordsInitialize:
|
|
48
|
+
() =>
|
|
49
|
+
({ dispatch, store }) => {
|
|
50
|
+
dispatch({
|
|
51
|
+
type: "COORD_INITIALIZE_START",
|
|
52
|
+
payload: {
|
|
53
|
+
_shouldInitialize: false,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
const map = store.selectMap();
|
|
58
|
+
map.on("pointermove", throttle(store.doCoordsPointerMove, 200));
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
doCoordsPointerMove:
|
|
63
|
-
e
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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",
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
});
|
|
60
|
+
dispatch({
|
|
61
|
+
type: "COORD_INITIALIZE_FINISH",
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
doCoordsPointerMove:
|
|
65
|
+
(e) =>
|
|
66
|
+
({ dispatch, store }) => {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
e.stopPropagation();
|
|
143
69
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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",
|
|
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;
|
|
75
|
+
|
|
76
|
+
dispatch({
|
|
77
|
+
type: "COORD_POSITION_UPDATE",
|
|
78
|
+
payload: {
|
|
79
|
+
values: { X, Y },
|
|
181
80
|
},
|
|
182
|
-
}
|
|
183
|
-
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
doRenderCoordsOverlay:
|
|
84
|
+
(center, coords) =>
|
|
85
|
+
({ dispatch, store }) => {
|
|
86
|
+
const map = store.selectMap();
|
|
87
|
+
const hasCoordsOverlay = store.selectCoordsOverlay();
|
|
184
88
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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);
|
|
146
|
+
|
|
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
|
+
},
|
|
199
156
|
},
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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");
|
|
181
|
+
|
|
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");
|
|
208
190
|
|
|
209
|
-
if (isNaN(x) || isNaN(y)) {
|
|
210
191
|
dispatch({
|
|
211
|
-
type: "
|
|
192
|
+
type: "COORD_COPIED",
|
|
212
193
|
payload: {
|
|
194
|
+
copyActive: false,
|
|
195
|
+
container: null,
|
|
213
196
|
notification: {
|
|
214
197
|
title: "Coordinate Display",
|
|
215
|
-
message:
|
|
216
|
-
level: "
|
|
198
|
+
message: msg,
|
|
199
|
+
level: "info",
|
|
217
200
|
},
|
|
218
201
|
},
|
|
219
202
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
store.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
+
},
|
|
227
250
|
selectCoordsValues: (state) => {
|
|
228
251
|
return state.coordinateDisplay.values;
|
|
229
252
|
},
|