@corpsmap/corpsmap 3.0.10 → 3.0.13
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/css/corpsmap.css +15 -6
- package/lib/dev.js +5086 -1294
- package/lib/prod.js +5086 -1294
- package/package.json +6 -1
- package/src/application-bundles/map-layers-bundle.js +16 -13
- package/src/application-controls/tree-list-folder.js +45 -27
- package/src/core-plugins/add-data/add-data-button.js +7 -8
- package/src/core-plugins/add-data/add-geojson.js +23 -19
- package/src/core-plugins/add-data/add-kmlfile.js +46 -0
- package/src/core-plugins/add-data/bundle.js +185 -111
- package/src/core-plugins/tree-view/download-bundle.js +3 -3
- package/src/core-plugins/tree-view/layer-subpanel/layer-subpanel.js +1 -1
- package/src/core-plugins/tree-view/tree-list-item-dataset.js +14 -3
- package/src/utils/load-plugins.test.js +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corpsmap/corpsmap",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "CorpsMap as React Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"react-dom": ">=16.x.x"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@mapbox/togeojson": "^0.16.0",
|
|
44
45
|
"@turf/bbox": "^6.0.1",
|
|
45
46
|
"@turf/bbox-polygon": "^6.0.1",
|
|
46
47
|
"@turf/boolean-crosses": "^6.0.1",
|
|
@@ -57,15 +58,19 @@
|
|
|
57
58
|
"async": "^2.6.1",
|
|
58
59
|
"classnames": "^2.2.5",
|
|
59
60
|
"css": "^2.2.4",
|
|
61
|
+
"decompress": "^4.2.1",
|
|
62
|
+
"extract-files": "^12.0.0",
|
|
60
63
|
"file-saver": "^2.0.2",
|
|
61
64
|
"is-html": "^2.0.0",
|
|
62
65
|
"jspdf": "^1.5.3",
|
|
66
|
+
"kmljs": "0.0.1",
|
|
63
67
|
"lodash": "^4.17.15",
|
|
64
68
|
"markdown-it": "^12.0.3",
|
|
65
69
|
"moment": "^2.24.0",
|
|
66
70
|
"money-clip": "^3.0.1",
|
|
67
71
|
"ol": "^6.4.3",
|
|
68
72
|
"ol-esri-style": "^2.0.7",
|
|
73
|
+
"parse2-kmz": "^1.0.5",
|
|
69
74
|
"proj4": "^2.4.4",
|
|
70
75
|
"react-data-grid": "^6.1.0",
|
|
71
76
|
"react-datepicker": "^2.9.6",
|
|
@@ -50,6 +50,7 @@ const createNode = (options, map) => {
|
|
|
50
50
|
favorite: false,
|
|
51
51
|
userDefaultLayer: false,
|
|
52
52
|
selectAllLayers: options.selectAllLayers,
|
|
53
|
+
hoverText: options.hoverText,
|
|
53
54
|
};
|
|
54
55
|
return node;
|
|
55
56
|
};
|
|
@@ -240,25 +241,24 @@ export default {
|
|
|
240
241
|
|
|
241
242
|
dispatch({ type: "LAYERS_LIST_UPDATED", payload: newLayers });
|
|
242
243
|
},
|
|
243
|
-
doActivateUserDefaultLayers:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
doActivateUserDefaultLayers:
|
|
245
|
+
() =>
|
|
246
|
+
({ dispatch, store }) => {
|
|
247
|
+
const userDefaultLayers = store.selectUserDefaultLayers();
|
|
248
|
+
const layers = store.selectLayers();
|
|
249
|
+
userDefaultLayers.forEach((lyr) => {
|
|
249
250
|
const node = layers[lyr.uid];
|
|
250
251
|
if (node && node.mapLayer) {
|
|
251
252
|
node.visible = true;
|
|
252
253
|
node.mapLayer.setVisible(true);
|
|
253
254
|
}
|
|
254
255
|
});
|
|
255
|
-
|
|
256
|
+
|
|
256
257
|
dispatch({
|
|
257
258
|
type: "LAYERS_LIST_UPDATED",
|
|
258
259
|
payload: Object.assign({}, layers),
|
|
259
260
|
});
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
},
|
|
262
262
|
|
|
263
263
|
doAddLayersBulk:
|
|
264
264
|
(optionsCollection) =>
|
|
@@ -520,6 +520,9 @@ export default {
|
|
|
520
520
|
const delim = url.indexOf("?") === -1 ? "?" : "&";
|
|
521
521
|
return `${url}${delim}label=true`;
|
|
522
522
|
}
|
|
523
|
+
// if (node.HoverText){
|
|
524
|
+
// set the text popup to the hover text value
|
|
525
|
+
// }
|
|
523
526
|
|
|
524
527
|
if (node.mapLayer) {
|
|
525
528
|
node.labelsOn = labelsOn;
|
|
@@ -620,14 +623,14 @@ export default {
|
|
|
620
623
|
payload: Object.assign({}, layers),
|
|
621
624
|
});
|
|
622
625
|
},
|
|
623
|
-
|
|
626
|
+
|
|
624
627
|
doUpdateUserDefaultLayers:
|
|
625
628
|
(type, lyr) =>
|
|
626
629
|
({ dispatch, store }) => {
|
|
627
630
|
const userDefaultLayers = store.selectUserDefaultLayers();
|
|
628
631
|
const layers = store.selectLayers();
|
|
629
632
|
const node = layers[lyr.uid];
|
|
630
|
-
|
|
633
|
+
|
|
631
634
|
if (type === "add") {
|
|
632
635
|
userDefaultLayers.push(node);
|
|
633
636
|
} else {
|
|
@@ -646,7 +649,7 @@ export default {
|
|
|
646
649
|
},
|
|
647
650
|
});
|
|
648
651
|
},
|
|
649
|
-
|
|
652
|
+
|
|
650
653
|
doLayerSetUserDefaultLayers:
|
|
651
654
|
(nodeId, userDefaultLayer) =>
|
|
652
655
|
({ dispatch, store }) => {
|
|
@@ -658,7 +661,7 @@ export default {
|
|
|
658
661
|
type: "LAYERS_LIST_UPDATED",
|
|
659
662
|
payload: Object.assign({}, layers),
|
|
660
663
|
});
|
|
661
|
-
|
|
664
|
+
},
|
|
662
665
|
|
|
663
666
|
selectFavoriteLayers: (state) => {
|
|
664
667
|
return state.layers.favoriteLayers;
|
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import classnames from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
3
|
|
|
4
4
|
class TreeListFolder extends React.Component {
|
|
5
|
-
render(){
|
|
6
|
-
const { item, collapsed, toggleCollapsed } = this.props;
|
|
5
|
+
render() {
|
|
6
|
+
const { displayName, item, collapsed, toggleCollapsed } = this.props;
|
|
7
|
+
|
|
8
|
+
const testText = "LAYER_X";
|
|
9
|
+
const hoverText = testText ? testText : displayName;
|
|
10
|
+
const { isOver, theme, mapZoom } = this.props;
|
|
11
|
+
|
|
12
|
+
const enabled = item.minzoom <= mapZoom && item.maxzoom >= mapZoom;
|
|
13
|
+
const itemTxtStyle = enabled ? { color: "#666" } : { color: "#bbb" };
|
|
14
|
+
|
|
7
15
|
const iconClass = classnames({
|
|
8
|
-
|
|
16
|
+
mdi: true,
|
|
9
17
|
"mdi-folder-open": !collapsed,
|
|
10
|
-
"mdi-folder": collapsed
|
|
11
|
-
})
|
|
18
|
+
"mdi-folder": collapsed,
|
|
19
|
+
});
|
|
12
20
|
const itemClass = classnames({
|
|
13
|
-
"tree-list-item-hover": false
|
|
14
|
-
})
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
"tree-list-item-hover": false,
|
|
22
|
+
});
|
|
23
|
+
const itemClassTest = classnames({
|
|
24
|
+
"cm-checkbox-inline": true,
|
|
25
|
+
"cm-checkbox-ellipsis": true,
|
|
26
|
+
"tree-list-item-hover": isOver,
|
|
27
|
+
});
|
|
28
|
+
const divStyle = {
|
|
29
|
+
display: "inline-block",
|
|
30
|
+
paddingLeft: "8px",
|
|
31
|
+
};
|
|
19
32
|
const count = item.children.length;
|
|
20
33
|
return (
|
|
21
34
|
<div>
|
|
22
|
-
<i
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
<i
|
|
36
|
+
title="Click to collapse or expand"
|
|
37
|
+
onClick={toggleCollapsed}
|
|
38
|
+
className={iconClass}
|
|
39
|
+
style={{ fontSize: "16px", cursor: "pointer" }}
|
|
40
|
+
></i>
|
|
27
41
|
<span>
|
|
28
|
-
<div
|
|
29
|
-
className={itemClass}
|
|
42
|
+
<div
|
|
43
|
+
className={itemClass}
|
|
30
44
|
style={divStyle}
|
|
31
|
-
onDoubleClick={toggleCollapsed}
|
|
32
|
-
|
|
45
|
+
onDoubleClick={toggleCollapsed}
|
|
46
|
+
>
|
|
47
|
+
{item.displayName}
|
|
33
48
|
</div>
|
|
34
|
-
<span>
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
<span>{" (" + count + ")"}</span>
|
|
50
|
+
<label
|
|
51
|
+
className={itemClassTest}
|
|
52
|
+
title={`${hoverText} ${!enabled ? "- zoom in to enable" : ""}`}
|
|
53
|
+
style={itemTxtStyle}
|
|
54
|
+
></label>
|
|
37
55
|
</span>
|
|
38
56
|
</div>
|
|
39
|
-
)
|
|
57
|
+
);
|
|
40
58
|
}
|
|
41
59
|
}
|
|
42
60
|
|
|
43
|
-
export default TreeListFolder;
|
|
61
|
+
export default TreeListFolder;
|
|
@@ -2,16 +2,17 @@ import React from "react";
|
|
|
2
2
|
import { connect } from "redux-bundler-react";
|
|
3
3
|
import {
|
|
4
4
|
BasicToolbarButton,
|
|
5
|
-
BasicToolbarMenu
|
|
5
|
+
BasicToolbarMenu,
|
|
6
6
|
} from "../../application-controls";
|
|
7
7
|
import AddGeoJsonButton from "./add-geojson";
|
|
8
8
|
import AddShapefileButton from "./add-shapefile";
|
|
9
|
+
import AddKmlFileButton from "./add-kmlfile";
|
|
9
10
|
|
|
10
11
|
class AddDataButton extends React.Component {
|
|
11
12
|
constructor(props) {
|
|
12
13
|
super(props);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
render() {
|
|
16
17
|
return (
|
|
17
18
|
<BasicToolbarButton
|
|
@@ -21,15 +22,13 @@ class AddDataButton extends React.Component {
|
|
|
21
22
|
onDeactivate={() => {}}
|
|
22
23
|
>
|
|
23
24
|
<BasicToolbarMenu>
|
|
24
|
-
<AddGeoJsonButton/>
|
|
25
|
-
<AddShapefileButton/>
|
|
25
|
+
<AddGeoJsonButton />
|
|
26
|
+
<AddShapefileButton />
|
|
27
|
+
<AddKmlFileButton />
|
|
26
28
|
</BasicToolbarMenu>
|
|
27
29
|
</BasicToolbarButton>
|
|
28
30
|
);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
export default connect(
|
|
33
|
-
"doNotificationsFire",
|
|
34
|
-
AddDataButton
|
|
35
|
-
);
|
|
34
|
+
export default connect("doNotificationsFire", AddDataButton);
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { BasicToolbarMenuItem } from
|
|
3
|
-
import { connect } from
|
|
4
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BasicToolbarMenuItem } from "../../application-controls";
|
|
3
|
+
import { connect } from "redux-bundler-react";
|
|
5
4
|
|
|
6
5
|
class AddGeoJsonButton extends React.Component {
|
|
7
|
-
constructor(props){
|
|
6
|
+
constructor(props) {
|
|
8
7
|
super(props);
|
|
9
8
|
this.handleClick = this.handleClick.bind(this);
|
|
10
9
|
this.handleFile = this.handleFile.bind(this);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
handleClick(e){
|
|
12
|
+
handleClick(e) {
|
|
14
13
|
this.geojsonInput.click();
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
handleFile(e){
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
handleFile(e) {
|
|
17
|
+
const { doAddDataFile } = this.props;
|
|
18
|
+
const file = this.geojsonInput.files[0];
|
|
19
|
+
doAddDataFile(file);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
render(){
|
|
22
|
+
render() {
|
|
24
23
|
return (
|
|
25
24
|
<BasicToolbarMenuItem
|
|
26
|
-
active={
|
|
25
|
+
active={false}
|
|
27
26
|
iconClass="ms ms-geojson icon-inline"
|
|
28
27
|
title="Add Local GeoJSON File"
|
|
29
28
|
text="Add Local GeoJSON File"
|
|
30
|
-
onClick={
|
|
29
|
+
onClick={this.handleClick}
|
|
31
30
|
passProps={{}}
|
|
32
31
|
disableSubmenu={true}
|
|
33
32
|
>
|
|
34
|
-
<input
|
|
33
|
+
<input
|
|
34
|
+
onChange={this.handleFile}
|
|
35
|
+
accept=".geojson,.json"
|
|
36
|
+
className="hidden"
|
|
37
|
+
type="file"
|
|
38
|
+
ref={(el) => {
|
|
39
|
+
this.geojsonInput = el;
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
35
42
|
</BasicToolbarMenuItem>
|
|
36
|
-
)
|
|
43
|
+
);
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
export default connect(
|
|
41
|
-
'doAddDataFile',
|
|
42
|
-
AddGeoJsonButton
|
|
43
|
-
);
|
|
47
|
+
export default connect("doAddDataFile", AddGeoJsonButton);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BasicToolbarMenuItem } from "../../application-controls";
|
|
3
|
+
import { connect } from "redux-bundler-react";
|
|
4
|
+
|
|
5
|
+
class AddKmlFileButton extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.handleClick = this.handleClick.bind(this);
|
|
9
|
+
this.handleFile = this.handleFile.bind(this);
|
|
10
|
+
}
|
|
11
|
+
handleClick(e) {
|
|
12
|
+
this.geojsonInput.click();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
handleFile(e) {
|
|
16
|
+
const { doAddDataFile } = this.props;
|
|
17
|
+
const file = this.geojsonInput.files[0];
|
|
18
|
+
doAddDataFile(file);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
return (
|
|
23
|
+
<BasicToolbarMenuItem
|
|
24
|
+
active={false}
|
|
25
|
+
iconClass="ms ms-kml icon-inline"
|
|
26
|
+
title="Add Local KML File"
|
|
27
|
+
text="Add Local KML File"
|
|
28
|
+
onClick={this.handleClick}
|
|
29
|
+
passProps={{}}
|
|
30
|
+
disableSubmenu={true}
|
|
31
|
+
>
|
|
32
|
+
<input
|
|
33
|
+
onChange={this.handleFile}
|
|
34
|
+
accept=".kml"
|
|
35
|
+
className="hidden"
|
|
36
|
+
type="file"
|
|
37
|
+
ref={(el) => {
|
|
38
|
+
this.geojsonInput = el;
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
</BasicToolbarMenuItem>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default connect("doAddDataFile", AddKmlFileButton);
|
|
@@ -2,6 +2,9 @@ import v4 from "uuid";
|
|
|
2
2
|
import GeoJSON from "ol/format/GeoJSON";
|
|
3
3
|
import { getLayer } from "../../openlayers-utils/layer-utilities";
|
|
4
4
|
import shp from "shpjs";
|
|
5
|
+
import KMLConvert from "@mapbox/togeojson";
|
|
6
|
+
import extractFiles from "extract-files/extractFiles.mjs";
|
|
7
|
+
import isExtractableFile from "extract-files/isExtractableFile.mjs";
|
|
5
8
|
|
|
6
9
|
export default {
|
|
7
10
|
name: "addData",
|
|
@@ -29,120 +32,191 @@ export default {
|
|
|
29
32
|
};
|
|
30
33
|
},
|
|
31
34
|
|
|
32
|
-
doDispatchNotification:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
35
|
+
doDispatchNotification:
|
|
36
|
+
(message) =>
|
|
37
|
+
({ dispatch, store }) => {
|
|
38
|
+
store.doNotificationsFire({
|
|
39
|
+
title: "Add Data Error",
|
|
40
|
+
message: message,
|
|
41
|
+
level: "danger",
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
doAddDataFile:
|
|
46
|
+
(file) =>
|
|
47
|
+
({ dispatch, store }) => {
|
|
48
|
+
store.doBasicToolbarDeactivate();
|
|
49
|
+
let uid, options;
|
|
50
|
+
let reader = new FileReader();
|
|
51
|
+
|
|
52
|
+
if (file && file.name.match(/\.(geojson|json)$/)) {
|
|
53
|
+
reader.onload = function () {
|
|
54
|
+
try {
|
|
55
|
+
const data = JSON.parse(reader.result);
|
|
56
|
+
store.doAddDataGeojson(file.name, data);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
store.doDispatchNotification(err.message || "Error adding data");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
reader.readAsText(file);
|
|
62
|
+
} else if (file && file.name.match(/\.(zip)$/)) {
|
|
63
|
+
reader.onload = function (e) {
|
|
64
|
+
try {
|
|
65
|
+
const buffer = e.currentTarget.result;
|
|
66
|
+
shp(buffer)
|
|
67
|
+
.then((geojson) => {
|
|
68
|
+
console.log(geojson);
|
|
69
|
+
store.doAddDataGeojson(file.name, geojson);
|
|
70
|
+
})
|
|
71
|
+
.catch((err) => {
|
|
72
|
+
store.doDispatchNotification(
|
|
73
|
+
err.message || "Error adding data"
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
} catch (err) {
|
|
77
|
+
store.doDispatchNotification(err.message || "Error adding data");
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
reader.readAsArrayBuffer(file);
|
|
81
|
+
} else if (file && file.name.match(/\.(kml)$/)) {
|
|
82
|
+
reader.onload = function (e) {
|
|
83
|
+
try {
|
|
84
|
+
let fileInfo = e.currentTarget.result;
|
|
85
|
+
let utf8decoder = new TextDecoder();
|
|
86
|
+
let u8arr = new Uint8Array(fileInfo);
|
|
87
|
+
let decodedFileInfo = utf8decoder.decode(u8arr);
|
|
88
|
+
console.log(decodedFileInfo);
|
|
89
|
+
|
|
90
|
+
// read in our KML file and then parse it
|
|
91
|
+
const parsedKML = new DOMParser().parseFromString(
|
|
92
|
+
decodedFileInfo,
|
|
93
|
+
"text/html"
|
|
94
|
+
);
|
|
95
|
+
// convert our kml to geojson and store the results
|
|
96
|
+
const geojson = KMLConvert.kml(parsedKML);
|
|
97
|
+
store.doAddDataGeojson(file.name, geojson);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
store.doDispatchNotification(err.message || "Error adding data");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
reader.readAsArrayBuffer(file);
|
|
103
|
+
} else if (file && file.name.match(/\.(kmz)$/)) {
|
|
104
|
+
reader.onload = function (e) {
|
|
105
|
+
try {
|
|
106
|
+
let fileInfo = e.currentTarget.result;
|
|
107
|
+
let utf8decoder = new TextDecoder();
|
|
108
|
+
let u8arr = new Uint8Array(fileInfo);
|
|
109
|
+
let decodedFileInfo = utf8decoder.decode(u8arr);
|
|
110
|
+
console.log(decodedFileInfo);
|
|
111
|
+
|
|
112
|
+
// read in our KML file and then parse it
|
|
113
|
+
// const KMZ = new DOMParser().parseFromString(decodedFileInfo);
|
|
114
|
+
// convert our kml to geojson and store the results
|
|
115
|
+
// const geojson = KMLConvert.kml(parsedKML);
|
|
116
|
+
|
|
117
|
+
// const file1 = new File(["1"], "BuxtonNC.kmz", {
|
|
118
|
+
// type: "text/plain",
|
|
119
|
+
// });
|
|
120
|
+
|
|
121
|
+
// const value = {
|
|
122
|
+
// a: file1,
|
|
123
|
+
// };
|
|
124
|
+
|
|
125
|
+
// const { clone, files } = extractFiles(
|
|
126
|
+
// value,
|
|
127
|
+
// isExtractableFile,
|
|
128
|
+
// "prefix"
|
|
129
|
+
// );
|
|
130
|
+
|
|
131
|
+
// store.doAddDataGeojson(file.name, geojson);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
store.doDispatchNotification(err.message || "Error adding data");
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
reader.readAsArrayBuffer(file);
|
|
138
|
+
} else {
|
|
139
|
+
if (file) {
|
|
140
|
+
store.doDispatchNotification(
|
|
141
|
+
`${file.name} is not a supported GeoJSON or shapfile file type`
|
|
142
|
+
);
|
|
68
143
|
}
|
|
69
|
-
};
|
|
70
|
-
reader.readAsArrayBuffer(file);
|
|
71
|
-
} else {
|
|
72
|
-
if (file) {
|
|
73
|
-
store.doDispatchNotification(
|
|
74
|
-
`${file.name} is not a supported GeoJSON or shapfile file type`
|
|
75
|
-
);
|
|
76
144
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
store
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
uid: uid,
|
|
103
|
-
displayName: filename,
|
|
104
|
-
parentUid: parentUid,
|
|
105
|
-
mapLayer: mapLayer,
|
|
106
|
-
serviceType: "LocalVector",
|
|
107
|
-
visible: true,
|
|
108
|
-
zoomTo: true,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
store.doSetCursor();
|
|
112
|
-
dispatch({ type: "ADD_DATA_ADDED_GEOJSON", payload: { key: uid } });
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
doMapDropDataFile: (e) => ({ dispatch, store }) => {
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
const files = e.dataTransfer.files;
|
|
119
|
-
const file = files[0];
|
|
120
|
-
store.doAddDataFile(file);
|
|
121
|
-
},
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
doAddDataGeojson:
|
|
148
|
+
(filename, geojson) =>
|
|
149
|
+
({ dispatch, store }) => {
|
|
150
|
+
store.doSetCursor("wait");
|
|
151
|
+
const parentUid = store.selectTreeViewRootId();
|
|
152
|
+
const uid = v4();
|
|
153
|
+
|
|
154
|
+
const mapLayer = getLayer({
|
|
155
|
+
serviceType: "LocalVector",
|
|
156
|
+
visible: true,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const features = new GeoJSON().readFeatures(geojson, {
|
|
160
|
+
dataProjection: "EPSG:4326",
|
|
161
|
+
featureProjection: "EPSG:3857",
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const src = mapLayer.getSource();
|
|
165
|
+
src.addFeatures(features);
|
|
166
|
+
|
|
167
|
+
if (store.hasOwnProperty("doGeojsonIdentAddFeatures")) {
|
|
168
|
+
store.doGeojsonIdentAddFeatures(uid, geojson, mapLayer);
|
|
169
|
+
}
|
|
122
170
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
171
|
+
store.doAddLayer({
|
|
172
|
+
uid: uid,
|
|
173
|
+
displayName: filename,
|
|
174
|
+
parentUid: parentUid,
|
|
175
|
+
mapLayer: mapLayer,
|
|
176
|
+
serviceType: "LocalVector",
|
|
177
|
+
visible: true,
|
|
178
|
+
zoomTo: true,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
store.doSetCursor();
|
|
182
|
+
dispatch({ type: "ADD_DATA_ADDED_GEOJSON", payload: { key: uid } });
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
doMapDropDataFile:
|
|
186
|
+
(e) =>
|
|
187
|
+
({ dispatch, store }) => {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
const files = e.dataTransfer.files;
|
|
191
|
+
const file = files[0];
|
|
192
|
+
store.doAddDataFile(file);
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
doAddMapDragDropListeners:
|
|
196
|
+
() =>
|
|
197
|
+
({ dispatch, store }) => {
|
|
198
|
+
dispatch({ type: "TURN_OFF_ADD_LISTENERS" });
|
|
199
|
+
const olMap = store.selectMap();
|
|
200
|
+
const map = olMap.getTargetElement();
|
|
201
|
+
|
|
202
|
+
map.addEventListener(
|
|
203
|
+
"dragleave",
|
|
204
|
+
function (e) {
|
|
205
|
+
e = e || event;
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
},
|
|
208
|
+
false
|
|
209
|
+
);
|
|
210
|
+
map.addEventListener(
|
|
211
|
+
"dragover",
|
|
212
|
+
function (e) {
|
|
213
|
+
e = e || event;
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
},
|
|
216
|
+
false
|
|
217
|
+
);
|
|
218
|
+
map.addEventListener("drop", store.doMapDropDataFile, false);
|
|
219
|
+
},
|
|
146
220
|
|
|
147
221
|
reactshouldAddListeners: (state) => {
|
|
148
222
|
if (state.addData.shouldAddListeners)
|