@mapcomponents/react-maplibre 0.1.85 → 0.1.87
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/CHANGELOG.md +22 -0
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +0 -2
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +0 -2
- package/dist/components/MlFeatureEditor/MlFeatureEditor.stories.d.ts +1 -0
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +1 -1
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.d.ts +26 -9
- package/dist/components/MlFollowGps/MlFollowGps.d.ts +0 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +1 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +1 -0
- package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +12 -2
- package/dist/components/MlMeasureTool/MlMeasureTool.stories.d.ts +1 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.stories.d.ts +1 -1
- package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +2 -1
- package/dist/components/MlScaleReference/MlScaleReference.stories.d.ts +1 -1
- package/dist/components/MlTemporalController/MlTemporalController.stories.d.ts +1 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.d.ts +1 -1
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +2 -0
- package/dist/contexts/LayerContext.d.ts +1 -0
- package/dist/hooks/useAddImage/useAddImage.d.ts +20 -0
- package/dist/hooks/useAddImage/useAddImage.stories.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +922 -681
- package/dist/index.esm.js.map +1 -1
- package/dist/ui_components/LayerList/LayerListItem.d.ts +2 -0
- package/dist/ui_components/LayerList/LayerListItemFactory.d.ts +1 -0
- package/dist/ui_components/LayerList/util/SortableContainer.d.ts +7 -0
- package/dist/ui_components/MapcomponentsTheme.d.ts +8 -0
- package/package.json +7 -5
package/dist/index.esm.js
CHANGED
|
@@ -27,6 +27,7 @@ var Divider = require('@mui/material/Divider');
|
|
|
27
27
|
var useMediaQuery = require('@mui/material/useMediaQuery');
|
|
28
28
|
var syncMove = require('@mapbox/mapbox-gl-sync-move');
|
|
29
29
|
var Paper = require('@mui/material/Paper');
|
|
30
|
+
var xmldom = require('@xmldom/xmldom');
|
|
30
31
|
var helpers = require('@turf/helpers');
|
|
31
32
|
var WMSCapabilities = require('wms-capabilities');
|
|
32
33
|
var InfoIcon = require('@mui/icons-material/Info');
|
|
@@ -41,15 +42,24 @@ var DialogActions = require('@mui/material/DialogActions');
|
|
|
41
42
|
var DialogContent = require('@mui/material/DialogContent');
|
|
42
43
|
var DialogContentText = require('@mui/material/DialogContentText');
|
|
43
44
|
var DialogTitle = require('@mui/material/DialogTitle');
|
|
45
|
+
var sortable = require('@dnd-kit/sortable');
|
|
46
|
+
var utilities = require('@dnd-kit/utilities');
|
|
44
47
|
var PlayArrowIcon = require('@mui/icons-material/PlayArrow');
|
|
45
48
|
var PauseIcon = require('@mui/icons-material/Pause');
|
|
46
49
|
var StopIcon = require('@mui/icons-material/Stop');
|
|
47
50
|
var FastForwardIcon = require('@mui/icons-material/FastForward');
|
|
48
51
|
var FastRewindIcon = require('@mui/icons-material/FastRewind');
|
|
49
|
-
var
|
|
52
|
+
var PentagonIcon = require('@mui/icons-material/Pentagon');
|
|
50
53
|
var system = require('@mui/system');
|
|
54
|
+
var EditIcon = require('@mui/icons-material/Edit');
|
|
55
|
+
var Tooltip = require('@mui/material/Tooltip');
|
|
51
56
|
var reactColor = require('react-color');
|
|
52
57
|
var TuneIcon = require('@mui/icons-material/Tune');
|
|
58
|
+
var ScatterPlotIcon = require('@mui/icons-material/ScatterPlot');
|
|
59
|
+
var PolylineIcon = require('@mui/icons-material/Polyline');
|
|
60
|
+
var d3 = require('d3');
|
|
61
|
+
var core = require('@dnd-kit/core');
|
|
62
|
+
var modifiers = require('@dnd-kit/modifiers');
|
|
53
63
|
var PlaylistAddIcon = require('@mui/icons-material/PlaylistAdd');
|
|
54
64
|
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
|
|
55
65
|
var AppBar = require('@mui/material/AppBar');
|
|
@@ -109,6 +119,7 @@ var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
|
|
|
109
119
|
var useMediaQuery__default = /*#__PURE__*/_interopDefaultLegacy(useMediaQuery);
|
|
110
120
|
var syncMove__default = /*#__PURE__*/_interopDefaultLegacy(syncMove);
|
|
111
121
|
var Paper__default = /*#__PURE__*/_interopDefaultLegacy(Paper);
|
|
122
|
+
var xmldom__namespace = /*#__PURE__*/_interopNamespace(xmldom);
|
|
112
123
|
var WMSCapabilities__default = /*#__PURE__*/_interopDefaultLegacy(WMSCapabilities);
|
|
113
124
|
var InfoIcon__default = /*#__PURE__*/_interopDefaultLegacy(InfoIcon);
|
|
114
125
|
var List__default = /*#__PURE__*/_interopDefaultLegacy(List);
|
|
@@ -126,8 +137,13 @@ var PauseIcon__default = /*#__PURE__*/_interopDefaultLegacy(PauseIcon);
|
|
|
126
137
|
var StopIcon__default = /*#__PURE__*/_interopDefaultLegacy(StopIcon);
|
|
127
138
|
var FastForwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastForwardIcon);
|
|
128
139
|
var FastRewindIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastRewindIcon);
|
|
129
|
-
var
|
|
140
|
+
var PentagonIcon__default = /*#__PURE__*/_interopDefaultLegacy(PentagonIcon);
|
|
141
|
+
var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
|
|
142
|
+
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
|
|
130
143
|
var TuneIcon__default = /*#__PURE__*/_interopDefaultLegacy(TuneIcon);
|
|
144
|
+
var ScatterPlotIcon__default = /*#__PURE__*/_interopDefaultLegacy(ScatterPlotIcon);
|
|
145
|
+
var PolylineIcon__default = /*#__PURE__*/_interopDefaultLegacy(PolylineIcon);
|
|
146
|
+
var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
|
|
131
147
|
var PlaylistAddIcon__default = /*#__PURE__*/_interopDefaultLegacy(PlaylistAddIcon);
|
|
132
148
|
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
|
|
133
149
|
var AppBar__default = /*#__PURE__*/_interopDefaultLegacy(AppBar);
|
|
@@ -783,7 +799,18 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
|
|
|
783
799
|
},
|
|
784
800
|
topToolbar: { barColor: '#000' },
|
|
785
801
|
navigation: { navColor: '#313131', navHover: '#747577' },
|
|
786
|
-
|
|
802
|
+
GPS: {
|
|
803
|
+
GPSActiveColor: '#fff',
|
|
804
|
+
GPSInactiveColor: '#fff',
|
|
805
|
+
GPSActiveBackgroundColor: '#747577',
|
|
806
|
+
},
|
|
807
|
+
compass: {
|
|
808
|
+
compColor: '#313131',
|
|
809
|
+
compHover: '#747577',
|
|
810
|
+
compStroke: '#d3dce1',
|
|
811
|
+
compNorth: '#cf003f',
|
|
812
|
+
compSouth: '#d3dcf0',
|
|
813
|
+
},
|
|
787
814
|
}
|
|
788
815
|
: {
|
|
789
816
|
primary: {
|
|
@@ -796,7 +823,18 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
|
|
|
796
823
|
},
|
|
797
824
|
topToolbar: { barColor: '#fff' },
|
|
798
825
|
navigation: { navColor: '#fff', navHover: '#f5f5f5' },
|
|
799
|
-
|
|
826
|
+
GPS: {
|
|
827
|
+
GPSActiveColor: '#009EE0',
|
|
828
|
+
GPSInactiveColor: '#000',
|
|
829
|
+
GPSActiveBackgroundColor: '#fff',
|
|
830
|
+
},
|
|
831
|
+
compass: {
|
|
832
|
+
compColor: '#fff',
|
|
833
|
+
compHover: '#f5f5f5',
|
|
834
|
+
compStroke: '#009ee0',
|
|
835
|
+
compNorth: '#cf003f',
|
|
836
|
+
compSouth: '#d3dcf0',
|
|
837
|
+
},
|
|
800
838
|
})) })); };
|
|
801
839
|
var getTheme = function (mode) {
|
|
802
840
|
var _a;
|
|
@@ -954,6 +992,7 @@ function LayerContextProvider(props) {
|
|
|
954
992
|
setTileUrl: setTileUrl,
|
|
955
993
|
moveUp: moveUp,
|
|
956
994
|
moveDown: moveDown,
|
|
995
|
+
moveLayer: moveLayer,
|
|
957
996
|
};
|
|
958
997
|
return React__default["default"].createElement(LayerContext.Provider, { value: value }, props.children);
|
|
959
998
|
}
|
|
@@ -1359,8 +1398,6 @@ var MlCenterPosition = function (props) {
|
|
|
1359
1398
|
};
|
|
1360
1399
|
MlCenterPosition.defaultProps = {
|
|
1361
1400
|
mapId: undefined,
|
|
1362
|
-
onColor: '#ececec',
|
|
1363
|
-
offColor: '#666',
|
|
1364
1401
|
};
|
|
1365
1402
|
|
|
1366
1403
|
/**
|
|
@@ -2547,7 +2584,7 @@ var MlFillExtrusionLayer = function (props) {
|
|
|
2547
2584
|
type: "fill-extrusion",
|
|
2548
2585
|
source: props.sourceId || "openmaptiles",
|
|
2549
2586
|
"source-layer": props.sourceLayer || "building",
|
|
2550
|
-
minzoom: props.minZoom ||
|
|
2587
|
+
minzoom: props.minZoom || 6,
|
|
2551
2588
|
paint: __assign({}, props.paint),
|
|
2552
2589
|
},
|
|
2553
2590
|
insertBeforeFirstSymbolLayer: true,
|
|
@@ -2763,7 +2800,12 @@ var MlFollowGps = function (props) {
|
|
|
2763
2800
|
isFollowed && userLocationGeoJson && (React__default["default"].createElement(MlGeoJsonLayer, { geojson: userLocationGeoJson, type: 'circle', paint: __assign({ 'circle-color': '#009ee0', 'circle-radius': 5, 'circle-stroke-color': '#fafaff', 'circle-stroke-width': 1 }, props.circlePaint), insertBeforeLayer: props.insertBeforeLayer })),
|
|
2764
2801
|
React__default["default"].createElement(material.Button, { variant: "navtools", sx: {
|
|
2765
2802
|
zIndex: 1002,
|
|
2766
|
-
color: isFollowed
|
|
2803
|
+
color: isFollowed
|
|
2804
|
+
? function (theme) { return theme.palette.GPS.GPSActiveColor; }
|
|
2805
|
+
: function (theme) { return theme.palette.GPS.GPSInactiveColor; },
|
|
2806
|
+
backgroundColor: isFollowed
|
|
2807
|
+
? function (theme) { return theme.palette.GPS.GPSActiveBackgroundColor; }
|
|
2808
|
+
: function (theme) { return theme.palette.navigation.navColor; },
|
|
2767
2809
|
}, disabled: locationAccessDenied, onClick: function () {
|
|
2768
2810
|
setIsFollowed(!isFollowed);
|
|
2769
2811
|
} },
|
|
@@ -2771,7 +2813,6 @@ var MlFollowGps = function (props) {
|
|
|
2771
2813
|
};
|
|
2772
2814
|
MlFollowGps.defaultProps = {
|
|
2773
2815
|
mapId: undefined,
|
|
2774
|
-
onColor: '#ececec',
|
|
2775
2816
|
offColor: '#666',
|
|
2776
2817
|
showAccuracyCircle: true,
|
|
2777
2818
|
showUserLocation: true,
|
|
@@ -2828,34 +2869,50 @@ var MlImageMarkerLayer = function (props) {
|
|
|
2828
2869
|
// miles: 1 / 2.58998811,
|
|
2829
2870
|
//};
|
|
2830
2871
|
function getUnitSquareMultiplier(measureType) {
|
|
2831
|
-
return measureType ===
|
|
2872
|
+
return measureType === 'miles' ? 1 / 2.58998811 : 1;
|
|
2832
2873
|
}
|
|
2833
2874
|
function getUnitLabel(measureType) {
|
|
2834
|
-
return measureType ===
|
|
2875
|
+
return measureType === 'miles' ? 'mi' : 'km';
|
|
2835
2876
|
}
|
|
2836
2877
|
var MlMeasureTool = function (props) {
|
|
2837
|
-
var _a = React.useState(0),
|
|
2878
|
+
var _a = React.useState({ value: 0, label: 'km' }), displayValue = _a[0], setDisplayValue = _a[1];
|
|
2838
2879
|
var _b = React.useState([]), currentFeatures = _b[0], setCurrentFeatures = _b[1];
|
|
2839
2880
|
React.useEffect(function () {
|
|
2840
2881
|
if (currentFeatures[0]) {
|
|
2841
|
-
|
|
2882
|
+
var result = props.measureType === 'polygon'
|
|
2883
|
+
// turf area does actually return mm^2 contrary to the documentation stating it will return m^2
|
|
2842
2884
|
? (turf__namespace.area(currentFeatures[0]) / 1000000) * getUnitSquareMultiplier(props.unit)
|
|
2843
|
-
: turf__namespace.length(currentFeatures[0], { units: props.unit })
|
|
2885
|
+
: turf__namespace.length(currentFeatures[0], { units: props.unit });
|
|
2886
|
+
if (typeof props.onChange === 'function') {
|
|
2887
|
+
props.onChange({ value: result, unit: props.unit, geojson: currentFeatures[0] });
|
|
2888
|
+
}
|
|
2889
|
+
if (result >= 0.1) {
|
|
2890
|
+
setDisplayValue({ value: result, label: getUnitLabel(props.unit) });
|
|
2891
|
+
}
|
|
2892
|
+
else {
|
|
2893
|
+
var label = 'm';
|
|
2894
|
+
var value = result * 1000000;
|
|
2895
|
+
if (getUnitLabel(props.unit) === 'mi') {
|
|
2896
|
+
label = 'in';
|
|
2897
|
+
value = result * 63360;
|
|
2898
|
+
}
|
|
2899
|
+
setDisplayValue({ value: value, label: label });
|
|
2900
|
+
}
|
|
2844
2901
|
}
|
|
2845
2902
|
}, [props.unit, currentFeatures]);
|
|
2846
2903
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2847
2904
|
React__default["default"].createElement(MlFeatureEditor, { onChange: function (features) {
|
|
2848
2905
|
setCurrentFeatures(features);
|
|
2849
|
-
}, mode: props.measureType ===
|
|
2850
|
-
|
|
2906
|
+
}, mode: props.measureType === 'polygon' ? 'draw_polygon' : 'draw_line_string' }),
|
|
2907
|
+
displayValue.value.toFixed(2),
|
|
2851
2908
|
" ",
|
|
2852
|
-
|
|
2853
|
-
props.measureType ===
|
|
2909
|
+
displayValue.label,
|
|
2910
|
+
props.measureType === 'polygon' ? '²' : ''));
|
|
2854
2911
|
};
|
|
2855
2912
|
MlMeasureTool.defaultProps = {
|
|
2856
2913
|
mapId: undefined,
|
|
2857
|
-
measureType:
|
|
2858
|
-
unit:
|
|
2914
|
+
measureType: 'line',
|
|
2915
|
+
unit: 'kilometers',
|
|
2859
2916
|
};
|
|
2860
2917
|
|
|
2861
2918
|
var _path$1, _path2$1;
|
|
@@ -2934,16 +2991,29 @@ var CompassBox = material.styled(material.Box)(function (_a) {
|
|
|
2934
2991
|
},
|
|
2935
2992
|
_b.circle = {
|
|
2936
2993
|
fill: theme.palette.compass.compColor,
|
|
2994
|
+
stroke: theme.palette.compass.compStroke,
|
|
2995
|
+
},
|
|
2996
|
+
_b.path = {
|
|
2997
|
+
fill: theme.palette.compass.compStroke,
|
|
2937
2998
|
},
|
|
2938
2999
|
_b['&:hover circle'] = {
|
|
2939
3000
|
fill: theme.palette.compass.compHover,
|
|
2940
3001
|
},
|
|
2941
3002
|
_b);
|
|
2942
3003
|
});
|
|
2943
|
-
var NeedleBox = material.styled(material.Box)({
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
3004
|
+
var NeedleBox = material.styled(material.Box)(function (_a) {
|
|
3005
|
+
var theme = _a.theme;
|
|
3006
|
+
return ({
|
|
3007
|
+
position: 'absolute',
|
|
3008
|
+
right: '21.4px',
|
|
3009
|
+
top: '6px',
|
|
3010
|
+
'path:nth-of-type(2)': {
|
|
3011
|
+
fill: theme.palette.compass.compSouth,
|
|
3012
|
+
},
|
|
3013
|
+
'path:nth-of-type(1)': {
|
|
3014
|
+
fill: theme.palette.compass.compNorth,
|
|
3015
|
+
},
|
|
3016
|
+
});
|
|
2947
3017
|
});
|
|
2948
3018
|
/**
|
|
2949
3019
|
* Navigation component that displays a compass component which indicates the current oriantation of the map it is registered for and offers controls to turn the bearing 90° left/right or reset north to point up.
|
|
@@ -3042,7 +3112,7 @@ var MlNavigationTools = function (props) {
|
|
|
3042
3112
|
}, [mapHook.map]);
|
|
3043
3113
|
return (React__default["default"].createElement(Box__default["default"], { sx: __assign(__assign({ zIndex: 501, position: 'absolute', display: 'flex', flexDirection: 'column', right: mediaIsMobile ? '15px' : '25px', bottom: mediaIsMobile ? '20px' : '30px' }, (mediaIsMobile ? { margin: '80px 10px 50px 10px' } : { marginTop: '50px' })), props.sx) },
|
|
3044
3114
|
React__default["default"].createElement(MlNavigationCompass, null),
|
|
3045
|
-
props.show3DButton && (React__default["default"].createElement(Button__default["default"], { variant: "navtools", onClick: adjustPitch }, pitch <
|
|
3115
|
+
props.show3DButton && (React__default["default"].createElement(Button__default["default"], { variant: "navtools", onClick: adjustPitch }, pitch < 29 ? '3D' : '2D')),
|
|
3046
3116
|
props.showFollowGpsButton && React__default["default"].createElement(MlFollowGps, null),
|
|
3047
3117
|
props.showCenterLocationButton && React__default["default"].createElement(MlCenterPosition, null),
|
|
3048
3118
|
React__default["default"].createElement(ButtonGroup__default["default"], { orientation: "vertical", sx: {
|
|
@@ -3898,7 +3968,7 @@ var toGeoJSON = function () {
|
|
|
3898
3968
|
if (x) {
|
|
3899
3969
|
norm(x);
|
|
3900
3970
|
}
|
|
3901
|
-
return x && x.textContent ||
|
|
3971
|
+
return x && x.textContent || '';
|
|
3902
3972
|
}
|
|
3903
3973
|
// get the contents of multiple text nodes, if present
|
|
3904
3974
|
function getMulti(x, ys) {
|
|
@@ -3917,11 +3987,11 @@ var toGeoJSON = function () {
|
|
|
3917
3987
|
}
|
|
3918
3988
|
// get one coordinate from a coordinate array, if any
|
|
3919
3989
|
function coord1(v) {
|
|
3920
|
-
return numarray(v.replace(removeSpace,
|
|
3990
|
+
return numarray(v.replace(removeSpace, '').split(','));
|
|
3921
3991
|
}
|
|
3922
3992
|
// get all coordinates from a coordinate array as [[],[]]
|
|
3923
3993
|
function coord(v) {
|
|
3924
|
-
var coords = v.replace(trimSpace,
|
|
3994
|
+
var coords = v.replace(trimSpace, '').split(splitSpace),
|
|
3925
3995
|
o = [];
|
|
3926
3996
|
for (var i = 0; i < coords.length; i++) {
|
|
3927
3997
|
o.push(coord1(coords[i]));
|
|
@@ -3929,11 +3999,11 @@ var toGeoJSON = function () {
|
|
|
3929
3999
|
return o;
|
|
3930
4000
|
}
|
|
3931
4001
|
function coordPair(x) {
|
|
3932
|
-
var ll = [attrf(x,
|
|
3933
|
-
ele = get1(x,
|
|
4002
|
+
var ll = [attrf(x, 'lon'), attrf(x, 'lat')],
|
|
4003
|
+
ele = get1(x, 'ele'),
|
|
3934
4004
|
// handle namespaced attribute in browser
|
|
3935
|
-
heartRate = get1(x,
|
|
3936
|
-
time = get1(x,
|
|
4005
|
+
heartRate = get1(x, 'gpxtpx:hr') || get1(x, 'hr'),
|
|
4006
|
+
time = get1(x, 'time'),
|
|
3937
4007
|
e;
|
|
3938
4008
|
if (ele) {
|
|
3939
4009
|
e = parseFloat(nodeVal(ele));
|
|
@@ -3951,22 +4021,21 @@ var toGeoJSON = function () {
|
|
|
3951
4021
|
// create a new feature collection parent object
|
|
3952
4022
|
function fc() {
|
|
3953
4023
|
return {
|
|
3954
|
-
type:
|
|
4024
|
+
type: 'FeatureCollection',
|
|
3955
4025
|
features: []
|
|
3956
4026
|
};
|
|
3957
4027
|
}
|
|
3958
4028
|
var serializer;
|
|
3959
|
-
if (typeof XMLSerializer !==
|
|
4029
|
+
if (typeof XMLSerializer !== 'undefined') {
|
|
3960
4030
|
/* istanbul ignore next */
|
|
3961
4031
|
serializer = new XMLSerializer();
|
|
3962
4032
|
} else {
|
|
3963
|
-
var isNodeEnv = (typeof process === "undefined" ? "undefined" : _typeof(process)) ===
|
|
3964
|
-
var isTitaniumEnv = (typeof Titanium === "undefined" ? "undefined" : _typeof(Titanium)) ===
|
|
3965
|
-
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) ===
|
|
3966
|
-
|
|
3967
|
-
serializer = new (require("xmldom").XMLSerializer)();
|
|
4033
|
+
var isNodeEnv = (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && !process.browser;
|
|
4034
|
+
var isTitaniumEnv = (typeof Titanium === "undefined" ? "undefined" : _typeof(Titanium)) === 'object';
|
|
4035
|
+
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && (isNodeEnv || isTitaniumEnv)) {
|
|
4036
|
+
serializer = xmldom__namespace.XMLSerializer;
|
|
3968
4037
|
} else {
|
|
3969
|
-
throw new Error(
|
|
4038
|
+
throw new Error('Unable to initialize serializer');
|
|
3970
4039
|
}
|
|
3971
4040
|
}
|
|
3972
4041
|
function xml2str(str) {
|
|
@@ -3986,32 +4055,32 @@ var toGeoJSON = function () {
|
|
|
3986
4055
|
styleMapIndex = {},
|
|
3987
4056
|
// atomic geospatial types supported by KML - MultiGeometry is
|
|
3988
4057
|
// handled separately
|
|
3989
|
-
geotypes = [
|
|
4058
|
+
geotypes = ['Polygon', 'LineString', 'Point', 'Track', 'gx:Track'],
|
|
3990
4059
|
// all root placemarks in the file
|
|
3991
|
-
placemarks = get(doc,
|
|
3992
|
-
styles = get(doc,
|
|
3993
|
-
styleMaps = get(doc,
|
|
4060
|
+
placemarks = get(doc, 'Placemark'),
|
|
4061
|
+
styles = get(doc, 'Style'),
|
|
4062
|
+
styleMaps = get(doc, 'StyleMap');
|
|
3994
4063
|
for (var k = 0; k < styles.length; k++) {
|
|
3995
4064
|
var hash = okhash(xml2str(styles[k])).toString(16);
|
|
3996
|
-
styleIndex[
|
|
4065
|
+
styleIndex['#' + attr(styles[k], 'id')] = hash;
|
|
3997
4066
|
styleByHash[hash] = styles[k];
|
|
3998
4067
|
}
|
|
3999
4068
|
for (var l = 0; l < styleMaps.length; l++) {
|
|
4000
|
-
styleIndex[
|
|
4001
|
-
var pairs = get(styleMaps[l],
|
|
4069
|
+
styleIndex['#' + attr(styleMaps[l], 'id')] = okhash(xml2str(styleMaps[l])).toString(16);
|
|
4070
|
+
var pairs = get(styleMaps[l], 'Pair');
|
|
4002
4071
|
var pairsMap = {};
|
|
4003
4072
|
for (var m = 0; m < pairs.length; m++) {
|
|
4004
|
-
pairsMap[nodeVal(get1(pairs[m],
|
|
4073
|
+
pairsMap[nodeVal(get1(pairs[m], 'key'))] = nodeVal(get1(pairs[m], 'styleUrl'));
|
|
4005
4074
|
}
|
|
4006
|
-
styleMapIndex[
|
|
4075
|
+
styleMapIndex['#' + attr(styleMaps[l], 'id')] = pairsMap;
|
|
4007
4076
|
}
|
|
4008
4077
|
for (var j = 0; j < placemarks.length; j++) {
|
|
4009
4078
|
gj.features = gj.features.concat(getPlacemark(placemarks[j]));
|
|
4010
4079
|
}
|
|
4011
4080
|
function kmlColor(v) {
|
|
4012
4081
|
var color, opacity;
|
|
4013
|
-
v = v ||
|
|
4014
|
-
if (v.substr(0, 1) ===
|
|
4082
|
+
v = v || '';
|
|
4083
|
+
if (v.substr(0, 1) === '#') {
|
|
4015
4084
|
v = v.substr(1);
|
|
4016
4085
|
}
|
|
4017
4086
|
if (v.length === 6 || v.length === 3) {
|
|
@@ -4019,20 +4088,20 @@ var toGeoJSON = function () {
|
|
|
4019
4088
|
}
|
|
4020
4089
|
if (v.length === 8) {
|
|
4021
4090
|
opacity = parseInt(v.substr(0, 2), 16) / 255;
|
|
4022
|
-
color =
|
|
4091
|
+
color = '#' + v.substr(6, 2) + v.substr(4, 2) + v.substr(2, 2);
|
|
4023
4092
|
}
|
|
4024
4093
|
return [color, isNaN(opacity) ? undefined : opacity];
|
|
4025
4094
|
}
|
|
4026
4095
|
function gxCoord(v) {
|
|
4027
|
-
return numarray(v.split(
|
|
4096
|
+
return numarray(v.split(' '));
|
|
4028
4097
|
}
|
|
4029
4098
|
function gxCoords(root) {
|
|
4030
|
-
var elems = get(root,
|
|
4099
|
+
var elems = get(root, 'coord'),
|
|
4031
4100
|
coords = [],
|
|
4032
4101
|
times = [];
|
|
4033
|
-
if (elems.length === 0) elems = get(root,
|
|
4102
|
+
if (elems.length === 0) elems = get(root, 'gx:coord');
|
|
4034
4103
|
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
|
|
4035
|
-
var timeElems = get(root,
|
|
4104
|
+
var timeElems = get(root, 'when');
|
|
4036
4105
|
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
|
|
4037
4106
|
return {
|
|
4038
4107
|
coords: coords,
|
|
@@ -4047,44 +4116,44 @@ var toGeoJSON = function () {
|
|
|
4047
4116
|
k,
|
|
4048
4117
|
geoms = [],
|
|
4049
4118
|
coordTimes = [];
|
|
4050
|
-
if (get1(root,
|
|
4051
|
-
return getGeometry(get1(root,
|
|
4119
|
+
if (get1(root, 'MultiGeometry')) {
|
|
4120
|
+
return getGeometry(get1(root, 'MultiGeometry'));
|
|
4052
4121
|
}
|
|
4053
|
-
if (get1(root,
|
|
4054
|
-
return getGeometry(get1(root,
|
|
4122
|
+
if (get1(root, 'MultiTrack')) {
|
|
4123
|
+
return getGeometry(get1(root, 'MultiTrack'));
|
|
4055
4124
|
}
|
|
4056
|
-
if (get1(root,
|
|
4057
|
-
return getGeometry(get1(root,
|
|
4125
|
+
if (get1(root, 'gx:MultiTrack')) {
|
|
4126
|
+
return getGeometry(get1(root, 'gx:MultiTrack'));
|
|
4058
4127
|
}
|
|
4059
4128
|
for (i = 0; i < geotypes.length; i++) {
|
|
4060
4129
|
geomNodes = get(root, geotypes[i]);
|
|
4061
4130
|
if (geomNodes) {
|
|
4062
4131
|
for (j = 0; j < geomNodes.length; j++) {
|
|
4063
4132
|
geomNode = geomNodes[j];
|
|
4064
|
-
if (geotypes[i] ===
|
|
4133
|
+
if (geotypes[i] === 'Point') {
|
|
4065
4134
|
geoms.push({
|
|
4066
|
-
type:
|
|
4067
|
-
coordinates: coord1(nodeVal(get1(geomNode,
|
|
4135
|
+
type: 'Point',
|
|
4136
|
+
coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))
|
|
4068
4137
|
});
|
|
4069
|
-
} else if (geotypes[i] ===
|
|
4138
|
+
} else if (geotypes[i] === 'LineString') {
|
|
4070
4139
|
geoms.push({
|
|
4071
|
-
type:
|
|
4072
|
-
coordinates: coord(nodeVal(get1(geomNode,
|
|
4140
|
+
type: 'LineString',
|
|
4141
|
+
coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))
|
|
4073
4142
|
});
|
|
4074
|
-
} else if (geotypes[i] ===
|
|
4075
|
-
var rings = get(geomNode,
|
|
4143
|
+
} else if (geotypes[i] === 'Polygon') {
|
|
4144
|
+
var rings = get(geomNode, 'LinearRing'),
|
|
4076
4145
|
coords = [];
|
|
4077
4146
|
for (k = 0; k < rings.length; k++) {
|
|
4078
|
-
coords.push(coord(nodeVal(get1(rings[k],
|
|
4147
|
+
coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));
|
|
4079
4148
|
}
|
|
4080
4149
|
geoms.push({
|
|
4081
|
-
type:
|
|
4150
|
+
type: 'Polygon',
|
|
4082
4151
|
coordinates: coords
|
|
4083
4152
|
});
|
|
4084
|
-
} else if (geotypes[i] ===
|
|
4153
|
+
} else if (geotypes[i] === 'Track' || geotypes[i] === 'gx:Track') {
|
|
4085
4154
|
var track = gxCoords(geomNode);
|
|
4086
4155
|
geoms.push({
|
|
4087
|
-
type:
|
|
4156
|
+
type: 'LineString',
|
|
4088
4157
|
coordinates: track.coords
|
|
4089
4158
|
});
|
|
4090
4159
|
if (track.times.length) coordTimes.push(track.times);
|
|
@@ -4101,22 +4170,22 @@ var toGeoJSON = function () {
|
|
|
4101
4170
|
var geomsAndTimes = getGeometry(root),
|
|
4102
4171
|
i,
|
|
4103
4172
|
properties = {},
|
|
4104
|
-
name = nodeVal(get1(root,
|
|
4105
|
-
address = nodeVal(get1(root,
|
|
4106
|
-
styleUrl = nodeVal(get1(root,
|
|
4107
|
-
description = nodeVal(get1(root,
|
|
4108
|
-
timeSpan = get1(root,
|
|
4109
|
-
timeStamp = get1(root,
|
|
4110
|
-
extendedData = get1(root,
|
|
4111
|
-
lineStyle = get1(root,
|
|
4112
|
-
polyStyle = get1(root,
|
|
4113
|
-
visibility = get1(root,
|
|
4173
|
+
name = nodeVal(get1(root, 'name')),
|
|
4174
|
+
address = nodeVal(get1(root, 'address')),
|
|
4175
|
+
styleUrl = nodeVal(get1(root, 'styleUrl')),
|
|
4176
|
+
description = nodeVal(get1(root, 'description')),
|
|
4177
|
+
timeSpan = get1(root, 'TimeSpan'),
|
|
4178
|
+
timeStamp = get1(root, 'TimeStamp'),
|
|
4179
|
+
extendedData = get1(root, 'ExtendedData'),
|
|
4180
|
+
lineStyle = get1(root, 'LineStyle'),
|
|
4181
|
+
polyStyle = get1(root, 'PolyStyle'),
|
|
4182
|
+
visibility = get1(root, 'visibility');
|
|
4114
4183
|
if (!geomsAndTimes.geoms.length) return [];
|
|
4115
4184
|
if (name) properties.name = name;
|
|
4116
4185
|
if (address) properties.address = address;
|
|
4117
4186
|
if (styleUrl) {
|
|
4118
|
-
if (styleUrl[0] !==
|
|
4119
|
-
styleUrl =
|
|
4187
|
+
if (styleUrl[0] !== '#') {
|
|
4188
|
+
styleUrl = '#' + styleUrl;
|
|
4120
4189
|
}
|
|
4121
4190
|
properties.styleUrl = styleUrl;
|
|
4122
4191
|
if (styleIndex[styleUrl]) {
|
|
@@ -4129,13 +4198,13 @@ var toGeoJSON = function () {
|
|
|
4129
4198
|
// Try to populate the lineStyle or polyStyle since we got the style hash
|
|
4130
4199
|
var style = styleByHash[properties.styleHash];
|
|
4131
4200
|
if (style) {
|
|
4132
|
-
if (!lineStyle) lineStyle = get1(style,
|
|
4133
|
-
if (!polyStyle) polyStyle = get1(style,
|
|
4134
|
-
var iconStyle = get1(style,
|
|
4201
|
+
if (!lineStyle) lineStyle = get1(style, 'LineStyle');
|
|
4202
|
+
if (!polyStyle) polyStyle = get1(style, 'PolyStyle');
|
|
4203
|
+
var iconStyle = get1(style, 'IconStyle');
|
|
4135
4204
|
if (iconStyle) {
|
|
4136
|
-
var icon = get1(iconStyle,
|
|
4205
|
+
var icon = get1(iconStyle, 'Icon');
|
|
4137
4206
|
if (icon) {
|
|
4138
|
-
var href = nodeVal(get1(icon,
|
|
4207
|
+
var href = nodeVal(get1(icon, 'href'));
|
|
4139
4208
|
if (href) properties.icon = href;
|
|
4140
4209
|
}
|
|
4141
4210
|
}
|
|
@@ -4143,44 +4212,44 @@ var toGeoJSON = function () {
|
|
|
4143
4212
|
}
|
|
4144
4213
|
if (description) properties.description = description;
|
|
4145
4214
|
if (timeSpan) {
|
|
4146
|
-
var begin = nodeVal(get1(timeSpan,
|
|
4147
|
-
var end = nodeVal(get1(timeSpan,
|
|
4215
|
+
var begin = nodeVal(get1(timeSpan, 'begin'));
|
|
4216
|
+
var end = nodeVal(get1(timeSpan, 'end'));
|
|
4148
4217
|
properties.timespan = {
|
|
4149
4218
|
begin: begin,
|
|
4150
4219
|
end: end
|
|
4151
4220
|
};
|
|
4152
4221
|
}
|
|
4153
4222
|
if (timeStamp) {
|
|
4154
|
-
properties.timestamp = nodeVal(get1(timeStamp,
|
|
4223
|
+
properties.timestamp = nodeVal(get1(timeStamp, 'when'));
|
|
4155
4224
|
}
|
|
4156
4225
|
if (lineStyle) {
|
|
4157
|
-
var linestyles = kmlColor(nodeVal(get1(lineStyle,
|
|
4226
|
+
var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))),
|
|
4158
4227
|
color = linestyles[0],
|
|
4159
4228
|
opacity = linestyles[1],
|
|
4160
|
-
width = parseFloat(nodeVal(get1(lineStyle,
|
|
4229
|
+
width = parseFloat(nodeVal(get1(lineStyle, 'width')));
|
|
4161
4230
|
if (color) properties.stroke = color;
|
|
4162
|
-
if (!isNaN(opacity)) properties[
|
|
4163
|
-
if (!isNaN(width)) properties[
|
|
4231
|
+
if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;
|
|
4232
|
+
if (!isNaN(width)) properties['stroke-width'] = width;
|
|
4164
4233
|
}
|
|
4165
4234
|
if (polyStyle) {
|
|
4166
|
-
var polystyles = kmlColor(nodeVal(get1(polyStyle,
|
|
4235
|
+
var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))),
|
|
4167
4236
|
pcolor = polystyles[0],
|
|
4168
4237
|
popacity = polystyles[1],
|
|
4169
|
-
fill = nodeVal(get1(polyStyle,
|
|
4170
|
-
outline = nodeVal(get1(polyStyle,
|
|
4238
|
+
fill = nodeVal(get1(polyStyle, 'fill')),
|
|
4239
|
+
outline = nodeVal(get1(polyStyle, 'outline'));
|
|
4171
4240
|
if (pcolor) properties.fill = pcolor;
|
|
4172
|
-
if (!isNaN(popacity)) properties[
|
|
4173
|
-
if (fill) properties[
|
|
4174
|
-
if (outline) properties[
|
|
4241
|
+
if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
|
|
4242
|
+
if (fill) properties['fill-opacity'] = fill === '1' ? properties['fill-opacity'] || 1 : 0;
|
|
4243
|
+
if (outline) properties['stroke-opacity'] = outline === '1' ? properties['stroke-opacity'] || 1 : 0;
|
|
4175
4244
|
}
|
|
4176
4245
|
if (extendedData) {
|
|
4177
|
-
var datas = get(extendedData,
|
|
4178
|
-
simpleDatas = get(extendedData,
|
|
4246
|
+
var datas = get(extendedData, 'Data'),
|
|
4247
|
+
simpleDatas = get(extendedData, 'SimpleData');
|
|
4179
4248
|
for (i = 0; i < datas.length; i++) {
|
|
4180
|
-
properties[datas[i].getAttribute(
|
|
4249
|
+
properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value'));
|
|
4181
4250
|
}
|
|
4182
4251
|
for (i = 0; i < simpleDatas.length; i++) {
|
|
4183
|
-
properties[simpleDatas[i].getAttribute(
|
|
4252
|
+
properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]);
|
|
4184
4253
|
}
|
|
4185
4254
|
}
|
|
4186
4255
|
if (visibility) {
|
|
@@ -4190,23 +4259,23 @@ var toGeoJSON = function () {
|
|
|
4190
4259
|
properties.coordTimes = geomsAndTimes.coordTimes.length === 1 ? geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes;
|
|
4191
4260
|
}
|
|
4192
4261
|
var feature = {
|
|
4193
|
-
type:
|
|
4262
|
+
type: 'Feature',
|
|
4194
4263
|
geometry: geomsAndTimes.geoms.length === 1 ? geomsAndTimes.geoms[0] : {
|
|
4195
|
-
type:
|
|
4264
|
+
type: 'GeometryCollection',
|
|
4196
4265
|
geometries: geomsAndTimes.geoms
|
|
4197
4266
|
},
|
|
4198
4267
|
properties: properties
|
|
4199
4268
|
};
|
|
4200
|
-
if (attr(root,
|
|
4269
|
+
if (attr(root, 'id')) feature.id = attr(root, 'id');
|
|
4201
4270
|
return [feature];
|
|
4202
4271
|
}
|
|
4203
4272
|
return gj;
|
|
4204
4273
|
},
|
|
4205
4274
|
gpx: function gpx(doc) {
|
|
4206
4275
|
var i,
|
|
4207
|
-
tracks = get(doc,
|
|
4208
|
-
routes = get(doc,
|
|
4209
|
-
waypoints = get(doc,
|
|
4276
|
+
tracks = get(doc, 'trk'),
|
|
4277
|
+
routes = get(doc, 'rte'),
|
|
4278
|
+
waypoints = get(doc, 'wpt'),
|
|
4210
4279
|
// a feature collection
|
|
4211
4280
|
gj = fc(),
|
|
4212
4281
|
feature;
|
|
@@ -4250,13 +4319,13 @@ var toGeoJSON = function () {
|
|
|
4250
4319
|
};
|
|
4251
4320
|
}
|
|
4252
4321
|
function getTrack(node) {
|
|
4253
|
-
var segments = get(node,
|
|
4322
|
+
var segments = get(node, 'trkseg'),
|
|
4254
4323
|
track = [],
|
|
4255
4324
|
times = [],
|
|
4256
4325
|
heartRates = [],
|
|
4257
4326
|
line;
|
|
4258
4327
|
for (var i = 0; i < segments.length; i++) {
|
|
4259
|
-
line = getPoints(segments[i],
|
|
4328
|
+
line = getPoints(segments[i], 'trkpt');
|
|
4260
4329
|
if (line) {
|
|
4261
4330
|
if (line.line) track.push(line.line);
|
|
4262
4331
|
if (line.times && line.times.length) times.push(line.times);
|
|
@@ -4276,28 +4345,28 @@ var toGeoJSON = function () {
|
|
|
4276
4345
|
}
|
|
4277
4346
|
if (track.length === 0) return;
|
|
4278
4347
|
var properties = getProperties(node);
|
|
4279
|
-
extend(properties, getLineStyle(get1(node,
|
|
4348
|
+
extend(properties, getLineStyle(get1(node, 'extensions')));
|
|
4280
4349
|
if (times.length) properties.coordTimes = track.length === 1 ? times[0] : times;
|
|
4281
4350
|
if (heartRates.length) properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;
|
|
4282
4351
|
return {
|
|
4283
|
-
type:
|
|
4352
|
+
type: 'Feature',
|
|
4284
4353
|
properties: properties,
|
|
4285
4354
|
geometry: {
|
|
4286
|
-
type: track.length === 1 ?
|
|
4355
|
+
type: track.length === 1 ? 'LineString' : 'MultiLineString',
|
|
4287
4356
|
coordinates: track.length === 1 ? track[0] : track
|
|
4288
4357
|
}
|
|
4289
4358
|
};
|
|
4290
4359
|
}
|
|
4291
4360
|
function getRoute(node) {
|
|
4292
|
-
var line = getPoints(node,
|
|
4361
|
+
var line = getPoints(node, 'rtept');
|
|
4293
4362
|
if (!line.line) return;
|
|
4294
4363
|
var prop = getProperties(node);
|
|
4295
|
-
extend(prop, getLineStyle(get1(node,
|
|
4364
|
+
extend(prop, getLineStyle(get1(node, 'extensions')));
|
|
4296
4365
|
var routeObj = {
|
|
4297
|
-
type:
|
|
4366
|
+
type: 'Feature',
|
|
4298
4367
|
properties: prop,
|
|
4299
4368
|
geometry: {
|
|
4300
|
-
type:
|
|
4369
|
+
type: 'LineString',
|
|
4301
4370
|
coordinates: line.line
|
|
4302
4371
|
}
|
|
4303
4372
|
};
|
|
@@ -4305,12 +4374,12 @@ var toGeoJSON = function () {
|
|
|
4305
4374
|
}
|
|
4306
4375
|
function getPoint(node) {
|
|
4307
4376
|
var prop = getProperties(node);
|
|
4308
|
-
extend(prop, getMulti(node, [
|
|
4377
|
+
extend(prop, getMulti(node, ['sym']));
|
|
4309
4378
|
return {
|
|
4310
|
-
type:
|
|
4379
|
+
type: 'Feature',
|
|
4311
4380
|
properties: prop,
|
|
4312
4381
|
geometry: {
|
|
4313
|
-
type:
|
|
4382
|
+
type: 'Point',
|
|
4314
4383
|
coordinates: coordPair(node).coordinates
|
|
4315
4384
|
}
|
|
4316
4385
|
};
|
|
@@ -4318,28 +4387,28 @@ var toGeoJSON = function () {
|
|
|
4318
4387
|
function getLineStyle(extensions) {
|
|
4319
4388
|
var style = {};
|
|
4320
4389
|
if (extensions) {
|
|
4321
|
-
var lineStyle = get1(extensions,
|
|
4390
|
+
var lineStyle = get1(extensions, 'line');
|
|
4322
4391
|
if (lineStyle) {
|
|
4323
|
-
var color = nodeVal(get1(lineStyle,
|
|
4324
|
-
opacity = parseFloat(nodeVal(get1(lineStyle,
|
|
4325
|
-
width = parseFloat(nodeVal(get1(lineStyle,
|
|
4392
|
+
var color = nodeVal(get1(lineStyle, 'color')),
|
|
4393
|
+
opacity = parseFloat(nodeVal(get1(lineStyle, 'opacity'))),
|
|
4394
|
+
width = parseFloat(nodeVal(get1(lineStyle, 'width')));
|
|
4326
4395
|
if (color) style.stroke = color;
|
|
4327
|
-
if (!isNaN(opacity)) style[
|
|
4396
|
+
if (!isNaN(opacity)) style['stroke-opacity'] = opacity;
|
|
4328
4397
|
// GPX width is in mm, convert to px with 96 px per inch
|
|
4329
|
-
if (!isNaN(width)) style[
|
|
4398
|
+
if (!isNaN(width)) style['stroke-width'] = width * 96 / 25.4;
|
|
4330
4399
|
}
|
|
4331
4400
|
}
|
|
4332
4401
|
return style;
|
|
4333
4402
|
}
|
|
4334
4403
|
function getProperties(node) {
|
|
4335
|
-
var prop = getMulti(node, [
|
|
4336
|
-
links = get(node,
|
|
4404
|
+
var prop = getMulti(node, ['name', 'cmt', 'desc', 'type', 'time', 'keywords']),
|
|
4405
|
+
links = get(node, 'link');
|
|
4337
4406
|
if (links.length) prop.links = [];
|
|
4338
4407
|
for (var i = 0, link; i < links.length; i++) {
|
|
4339
4408
|
link = {
|
|
4340
|
-
href: attr(links[i],
|
|
4409
|
+
href: attr(links[i], 'href')
|
|
4341
4410
|
};
|
|
4342
|
-
extend(link, getMulti(links[i], [
|
|
4411
|
+
extend(link, getMulti(links[i], ['text', 'type']));
|
|
4343
4412
|
prop.links.push(link);
|
|
4344
4413
|
}
|
|
4345
4414
|
return prop;
|
|
@@ -5309,6 +5378,17 @@ ConfirmDialog.defaultProps = {
|
|
|
5309
5378
|
text: 'Are you sure?',
|
|
5310
5379
|
};
|
|
5311
5380
|
|
|
5381
|
+
function SortableContainer(_a) {
|
|
5382
|
+
var children = _a.children, layerId = _a.layerId;
|
|
5383
|
+
var _b = sortable.useSortable({
|
|
5384
|
+
id: layerId,
|
|
5385
|
+
}), attributes = _b.attributes, listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform;
|
|
5386
|
+
var style = {
|
|
5387
|
+
transform: utilities.CSS.Transform.toString(transform),
|
|
5388
|
+
};
|
|
5389
|
+
return (React__default["default"].createElement("li", __assign({ ref: setNodeRef, style: style }, attributes, listeners), children));
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5312
5392
|
var originShift = (2 * Math.PI * 6378137) / 2.0;
|
|
5313
5393
|
var lngLatToMeters = function (lnglat, accuracy) {
|
|
5314
5394
|
if (accuracy === void 0) { accuracy = { enable: true, decimal: 1 }; }
|
|
@@ -5523,57 +5603,59 @@ var MlWmsLoader = function (props) {
|
|
|
5523
5603
|
}
|
|
5524
5604
|
}
|
|
5525
5605
|
}, [capabilities, mapHook.map]);
|
|
5606
|
+
var listContent = (React__default["default"].createElement(ListItem__default["default"], { secondaryAction: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5607
|
+
props.buttons,
|
|
5608
|
+
props.featureInfoEnabled && (React__default["default"].createElement(IconButton__default["default"], { sx: {
|
|
5609
|
+
padding: '4px',
|
|
5610
|
+
marginTop: '-3px',
|
|
5611
|
+
marginRight: '4px',
|
|
5612
|
+
background: function (theme) {
|
|
5613
|
+
if (!(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })))
|
|
5614
|
+
return 'initial';
|
|
5615
|
+
if (_featureInfoEventsEnabled)
|
|
5616
|
+
return theme.palette.info.light;
|
|
5617
|
+
return theme.palette.grey[300];
|
|
5618
|
+
},
|
|
5619
|
+
}, "aria-label": "featureinfo", onClick: function () {
|
|
5620
|
+
if (typeof (props === null || props === void 0 ? void 0 : props.setFeatureInfoActive) === 'function') {
|
|
5621
|
+
props.setFeatureInfoActive(function (current) { return !current; });
|
|
5622
|
+
}
|
|
5623
|
+
else {
|
|
5624
|
+
setFeatureInfoEventsEnabled(function (current) { return !current; });
|
|
5625
|
+
}
|
|
5626
|
+
}, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
|
|
5627
|
+
React__default["default"].createElement(InfoIcon__default["default"], null))),
|
|
5628
|
+
React__default["default"].createElement(IconButton__default["default"], { edge: props.showDeleteButton ? false : 'end', sx: __assign({ padding: '4px', marginTop: '-3px' }, (props.showDeleteButton ? { marginRight: '4px' } : {})), "aria-label": "open", onClick: function () { return setOpen(function (current) { return !current; }); } }, open ? React__default["default"].createElement(iconsMaterial.ExpandLess, null) : React__default["default"].createElement(iconsMaterial.ExpandMore, null)),
|
|
5629
|
+
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5630
|
+
React__default["default"].createElement(IconButton__default["default"], { "aria-label": "delete", edge: "end", onClick: function () {
|
|
5631
|
+
if (typeof props.onConfigChange === 'function') {
|
|
5632
|
+
setShowDeletionConfirmationDialog(true);
|
|
5633
|
+
}
|
|
5634
|
+
}, sx: { padding: '4px', marginTop: '-3px' } },
|
|
5635
|
+
React__default["default"].createElement(DeleteIcon__default["default"], null)),
|
|
5636
|
+
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
5637
|
+
if (typeof props.onConfigChange === 'function') {
|
|
5638
|
+
props.onConfigChange(false);
|
|
5639
|
+
}
|
|
5640
|
+
}, onCancel: function () {
|
|
5641
|
+
setShowDeletionConfirmationDialog(false);
|
|
5642
|
+
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" }))))), sx: {
|
|
5643
|
+
paddingRight: 0,
|
|
5644
|
+
paddingLeft: 0,
|
|
5645
|
+
paddingTop: 0,
|
|
5646
|
+
paddingBottom: '4px',
|
|
5647
|
+
} },
|
|
5648
|
+
React__default["default"].createElement(material.ListItemIcon, { sx: { minWidth: '30px' } },
|
|
5649
|
+
React__default["default"].createElement(material.Checkbox, { sx: { padding: 0 }, checked: visible, onClick: function () {
|
|
5650
|
+
setVisible(function (val) { return !val; });
|
|
5651
|
+
} })),
|
|
5652
|
+
React__default["default"].createElement(ListItemText__default["default"], { primary: name, variant: "layerlist" })));
|
|
5526
5653
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5527
5654
|
error && (React__default["default"].createElement(material.Snackbar, null,
|
|
5528
5655
|
React__default["default"].createElement(material.Box, null, error))),
|
|
5529
5656
|
wmsUrl && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5530
|
-
React__default["default"].createElement(
|
|
5531
|
-
|
|
5532
|
-
props.featureInfoEnabled && (React__default["default"].createElement(IconButton__default["default"], { sx: {
|
|
5533
|
-
padding: '4px',
|
|
5534
|
-
marginTop: '-3px',
|
|
5535
|
-
marginRight: '4px',
|
|
5536
|
-
background: function (theme) {
|
|
5537
|
-
if (!(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })))
|
|
5538
|
-
return 'initial';
|
|
5539
|
-
if (_featureInfoEventsEnabled)
|
|
5540
|
-
return theme.palette.info.light;
|
|
5541
|
-
return theme.palette.grey[300];
|
|
5542
|
-
},
|
|
5543
|
-
}, "aria-label": "featureinfo", onClick: function () {
|
|
5544
|
-
if (typeof (props === null || props === void 0 ? void 0 : props.setFeatureInfoActive) === 'function') {
|
|
5545
|
-
props.setFeatureInfoActive(function (current) { return !current; });
|
|
5546
|
-
}
|
|
5547
|
-
else {
|
|
5548
|
-
setFeatureInfoEventsEnabled(function (current) { return !current; });
|
|
5549
|
-
}
|
|
5550
|
-
}, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
|
|
5551
|
-
React__default["default"].createElement(InfoIcon__default["default"], null))),
|
|
5552
|
-
React__default["default"].createElement(IconButton__default["default"], { edge: props.showDeleteButton ? false : 'end', sx: __assign({ padding: '4px', marginTop: '-3px' }, (props.showDeleteButton ? { marginRight: '4px' } : {})), "aria-label": "open", onClick: function () { return setOpen(function (current) { return !current; }); } }, open ? React__default["default"].createElement(iconsMaterial.ExpandLess, null) : React__default["default"].createElement(iconsMaterial.ExpandMore, null)),
|
|
5553
|
-
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5554
|
-
React__default["default"].createElement(IconButton__default["default"], { "aria-label": "delete", edge: "end", onClick: function () {
|
|
5555
|
-
if (typeof props.onConfigChange === 'function') {
|
|
5556
|
-
setShowDeletionConfirmationDialog(true);
|
|
5557
|
-
}
|
|
5558
|
-
}, sx: { padding: '4px', marginTop: '-3px' } },
|
|
5559
|
-
React__default["default"].createElement(DeleteIcon__default["default"], null)),
|
|
5560
|
-
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
5561
|
-
if (typeof props.onConfigChange === 'function') {
|
|
5562
|
-
props.onConfigChange(false);
|
|
5563
|
-
}
|
|
5564
|
-
}, onCancel: function () {
|
|
5565
|
-
setShowDeletionConfirmationDialog(false);
|
|
5566
|
-
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" }))))), sx: {
|
|
5567
|
-
paddingRight: 0,
|
|
5568
|
-
paddingLeft: 0,
|
|
5569
|
-
paddingTop: 0,
|
|
5570
|
-
paddingBottom: '4px',
|
|
5571
|
-
} },
|
|
5572
|
-
React__default["default"].createElement(material.ListItemIcon, { sx: { minWidth: '30px' } },
|
|
5573
|
-
React__default["default"].createElement(material.Checkbox, { sx: { padding: 0 }, checked: visible, onClick: function () {
|
|
5574
|
-
setVisible(function (val) { return !val; });
|
|
5575
|
-
} })),
|
|
5576
|
-
React__default["default"].createElement(ListItemText__default["default"], { primary: name, variant: "layerlist" })),
|
|
5657
|
+
props.layerId && props.sortable && (React__default["default"].createElement(SortableContainer, { layerId: props.layerId }, listContent)),
|
|
5658
|
+
props.layerId && !props.sortable && (listContent),
|
|
5577
5659
|
React__default["default"].createElement(material.Box, { sx: { display: open ? 'block' : 'none' } },
|
|
5578
5660
|
React__default["default"].createElement(List__default["default"], { dense: true, component: "div", disablePadding: true, sx: { paddingLeft: '18px' } }, wmsUrl &&
|
|
5579
5661
|
((_j = layers === null || layers === void 0 ? void 0 : layers.map) === null || _j === void 0 ? void 0 : _j.call(layers, function (layer, idx) {
|
|
@@ -6182,385 +6264,80 @@ MlTerrainLayer.defaultProps = {
|
|
|
6182
6264
|
mapId: undefined,
|
|
6183
6265
|
};
|
|
6184
6266
|
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6267
|
+
var ListItemStyled$1 = system.styled(material.ListItem)({
|
|
6268
|
+
paddingRight: 0,
|
|
6269
|
+
paddingLeft: 0,
|
|
6270
|
+
paddingTop: 0,
|
|
6271
|
+
paddingBottom: '4px',
|
|
6272
|
+
});
|
|
6273
|
+
var ListItemIconStyled = system.styled(material.ListItemIcon)({
|
|
6274
|
+
minWidth: '30px',
|
|
6275
|
+
});
|
|
6276
|
+
var IconButtonStyled$1 = system.styled(material.IconButton)({
|
|
6277
|
+
marginRight: '0px',
|
|
6278
|
+
padding: '0px',
|
|
6279
|
+
});
|
|
6280
|
+
var CheckboxStyled$1 = system.styled(material.Checkbox)({
|
|
6281
|
+
padding: 0,
|
|
6282
|
+
marginRight: '5px',
|
|
6283
|
+
});
|
|
6284
|
+
var BoxStyled$1 = system.styled(system.Box)(function (_a) {
|
|
6285
|
+
var open = _a.open;
|
|
6286
|
+
return ({
|
|
6287
|
+
display: open ? 'block' : 'none',
|
|
6205
6288
|
});
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
React.
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
mapHook.map.map.setZoom(zoom.current);
|
|
6218
|
-
}
|
|
6219
|
-
}, [mapHook.map, props.zoom]);
|
|
6220
|
-
React.useEffect(function () {
|
|
6221
|
-
if (!mapHook.map)
|
|
6222
|
-
return;
|
|
6223
|
-
pitch.current = props.pitch;
|
|
6224
|
-
if (typeof pitch.current !== 'undefined' && pitch.current !== mapHook.map.map.getPitch()) {
|
|
6225
|
-
mapHook.map.map.setPitch(pitch.current);
|
|
6226
|
-
}
|
|
6227
|
-
}, [mapHook.map, props.pitch]);
|
|
6228
|
-
React.useEffect(function () {
|
|
6229
|
-
speed.current = props.speed;
|
|
6230
|
-
}, [props.speed]);
|
|
6231
|
-
var disableInteractivity = React.useCallback(function () {
|
|
6232
|
-
if (!mapHook.map)
|
|
6233
|
-
return;
|
|
6234
|
-
mapHook.map.map['scrollZoom'].disable();
|
|
6235
|
-
mapHook.map.map['boxZoom'].disable();
|
|
6236
|
-
mapHook.map.map['dragRotate'].disable();
|
|
6237
|
-
mapHook.map.map['dragPan'].disable();
|
|
6238
|
-
mapHook.map.map['keyboard'].disable();
|
|
6239
|
-
mapHook.map.map['doubleClickZoom'].disable();
|
|
6240
|
-
mapHook.map.map['touchZoomRotate'].disable();
|
|
6241
|
-
}, [mapHook.map]);
|
|
6242
|
-
var enableInteractivity = React.useCallback(function () {
|
|
6243
|
-
if (!mapHook.map)
|
|
6244
|
-
return;
|
|
6245
|
-
mapHook.map.map['scrollZoom'].enable();
|
|
6246
|
-
mapHook.map.map['boxZoom'].enable();
|
|
6247
|
-
mapHook.map.map['dragRotate'].enable();
|
|
6248
|
-
mapHook.map.map['dragPan'].enable();
|
|
6249
|
-
mapHook.map.map['keyboard'].enable();
|
|
6250
|
-
mapHook.map.map['doubleClickZoom'].enable();
|
|
6251
|
-
mapHook.map.map['touchZoomRotate'].enable();
|
|
6252
|
-
}, [mapHook.map]);
|
|
6253
|
-
function centerRoute() {
|
|
6254
|
-
if (!mapHook.map || !props.route)
|
|
6255
|
-
return;
|
|
6256
|
-
var bbox = turf__namespace.bbox(props.route);
|
|
6257
|
-
var bounds;
|
|
6258
|
-
if (bbox && bbox.length > 3) {
|
|
6259
|
-
bounds = [
|
|
6260
|
-
[bbox[0], bbox[1]],
|
|
6261
|
-
[bbox[2], bbox[3]],
|
|
6262
|
-
];
|
|
6263
|
-
mapHook.map.map.fitBounds(bounds, { padding: 100 });
|
|
6289
|
+
});
|
|
6290
|
+
var ListStyled$1 = system.styled(material.List)({
|
|
6291
|
+
marginLeft: '50px',
|
|
6292
|
+
});
|
|
6293
|
+
function LayerListFolder(_a) {
|
|
6294
|
+
var _b = _a.visible, visible = _b === void 0 ? true : _b, name = _a.name, children = _a.children, setVisible = _a.setVisible;
|
|
6295
|
+
var _c = React.useState(false), open = _c[0], setOpen = _c[1];
|
|
6296
|
+
var _d = React.useState(true), localVisible = _d[0], setLocalVisible = _d[1];
|
|
6297
|
+
var _visible = React.useMemo(function () {
|
|
6298
|
+
if (!visible) {
|
|
6299
|
+
return false;
|
|
6264
6300
|
}
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
var alongRoutelati = turf__namespace.along(props.route, step.current * kmPerStep).geometry
|
|
6275
|
-
.coordinates;
|
|
6276
|
-
if (step.current * kmPerStep < routeDistance) {
|
|
6277
|
-
mapHook.map.map.easeTo({
|
|
6278
|
-
center: alongRoutelati,
|
|
6279
|
-
bearing: turf__namespace.bearing(turf__namespace.point([mapHook.map.map.getCenter().lng, mapHook.map.map.getCenter().lat]), turf__namespace.point(alongRoutelati)),
|
|
6280
|
-
duration: stepDuration,
|
|
6281
|
-
essential: true,
|
|
6301
|
+
return localVisible;
|
|
6302
|
+
}, [visible, localVisible]);
|
|
6303
|
+
var _children = React.useMemo(function () {
|
|
6304
|
+
if (children) {
|
|
6305
|
+
if (Array.isArray(children)) {
|
|
6306
|
+
return children.map(function (element) {
|
|
6307
|
+
return React__default["default"].cloneElement(element, {
|
|
6308
|
+
visible: _visible,
|
|
6309
|
+
});
|
|
6282
6310
|
});
|
|
6283
|
-
if (typeof speed.current !== 'undefined') {
|
|
6284
|
-
step.current = step.current + speed.current;
|
|
6285
|
-
}
|
|
6286
|
-
else {
|
|
6287
|
-
step.current++;
|
|
6288
|
-
}
|
|
6289
|
-
console.log('PAN MOVE');
|
|
6290
|
-
setTimeout(function () {
|
|
6291
|
-
play();
|
|
6292
|
-
}, 100);
|
|
6293
|
-
}
|
|
6294
|
-
else {
|
|
6295
|
-
mapHook.map.map.setPitch(0);
|
|
6296
|
-
centerRoute();
|
|
6297
|
-
enableInteractivity();
|
|
6298
|
-
console.log('ENABLE CONTROLS');
|
|
6299
|
-
step.current = 1;
|
|
6300
6311
|
}
|
|
6312
|
+
return React__default["default"].cloneElement(children, {
|
|
6313
|
+
visible: _visible,
|
|
6314
|
+
});
|
|
6301
6315
|
}
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
return
|
|
6327
|
-
play: play,
|
|
6328
|
-
reset: reset,
|
|
6329
|
-
};
|
|
6330
|
-
};
|
|
6331
|
-
useCameraFollowPath.defaultProps = {
|
|
6332
|
-
mapId: undefined,
|
|
6333
|
-
zoom: 18,
|
|
6334
|
-
};
|
|
6335
|
-
|
|
6336
|
-
function useLayerFilter(props) {
|
|
6337
|
-
var mapHook = useMap({ mapId: props.mapId });
|
|
6338
|
-
React.useEffect(function () {
|
|
6339
|
-
if (!mapHook.map || !props.layerId || !props.filter)
|
|
6340
|
-
return;
|
|
6341
|
-
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
6342
|
-
var _layerId_1 = props.layerId;
|
|
6343
|
-
mapHook.map.map.setFilter(_layerId_1, props.filter);
|
|
6344
|
-
return function () {
|
|
6345
|
-
if (mapHook.map) {
|
|
6346
|
-
mapHook.map.map.setFilter(_layerId_1, null);
|
|
6347
|
-
}
|
|
6348
|
-
};
|
|
6349
|
-
}
|
|
6350
|
-
return;
|
|
6351
|
-
}, [props, mapHook.map]);
|
|
6352
|
-
return {};
|
|
6353
|
-
}
|
|
6354
|
-
|
|
6355
|
-
var touchEquivalents = {
|
|
6356
|
-
mousedown: 'touchstart',
|
|
6357
|
-
mouseup: 'touchend',
|
|
6358
|
-
mousemove: 'touchmove'
|
|
6359
|
-
};
|
|
6360
|
-
var touchEquivalentsKeys = Object.keys(touchEquivalents);
|
|
6361
|
-
function useLayerEvent(props) {
|
|
6362
|
-
var mapState = useMapState({
|
|
6363
|
-
mapId: props.mapId,
|
|
6364
|
-
watch: {
|
|
6365
|
-
layers: true
|
|
6366
|
-
}
|
|
6367
|
-
});
|
|
6368
|
-
var mapHook = useMap({
|
|
6369
|
-
mapId: props.mapId
|
|
6370
|
-
});
|
|
6371
|
-
React.useEffect(function () {
|
|
6372
|
-
if (!mapHook.map) return true;
|
|
6373
|
-
if (typeof props.condition !== 'undefined' && props.condition === false) return;
|
|
6374
|
-
//console.log('useLayerEvent');
|
|
6375
|
-
//console.log(mapState);
|
|
6376
|
-
|
|
6377
|
-
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
6378
|
-
//console.log("layer avail");
|
|
6379
|
-
var _event = props.event;
|
|
6380
|
-
var _layerId = props.layerId;
|
|
6381
|
-
var _eventHandler = props.eventHandler;
|
|
6382
|
-
|
|
6383
|
-
//console.log(_event);
|
|
6384
|
-
mapHook.map.on(_event, _layerId, _eventHandler, mapHook.componentId);
|
|
6385
|
-
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
6386
|
-
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
6387
|
-
mapHook.map.on(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
6388
|
-
}
|
|
6389
|
-
}
|
|
6390
|
-
return function () {
|
|
6391
|
-
mapHook.map.off(_event, _layerId, _eventHandler);
|
|
6392
|
-
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
6393
|
-
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
6394
|
-
mapHook.map.off(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
6395
|
-
}
|
|
6396
|
-
}
|
|
6397
|
-
};
|
|
6398
|
-
}
|
|
6399
|
-
}, [props, mapState, mapHook.map]);
|
|
6400
|
-
return {};
|
|
6401
|
-
}
|
|
6402
|
-
|
|
6403
|
-
var useLayerContext = function () {
|
|
6404
|
-
var layerContext = React.useContext(LayerContext);
|
|
6405
|
-
return layerContext;
|
|
6406
|
-
};
|
|
6407
|
-
|
|
6408
|
-
/**
|
|
6409
|
-
* Enables the use of custom protocols (basically custom tile load functions) in the maplibre-gl-js library.
|
|
6410
|
-
*
|
|
6411
|
-
*/
|
|
6412
|
-
var useAddProtocol = function (props) {
|
|
6413
|
-
React.useEffect(function () {
|
|
6414
|
-
if (!props.protocol || typeof props.handler !== 'function')
|
|
6415
|
-
return;
|
|
6416
|
-
maplibregl__default["default"].addProtocol(props.protocol, props.handler);
|
|
6417
|
-
return function () {
|
|
6418
|
-
maplibregl__default["default"].removeProtocol(props.protocol);
|
|
6419
|
-
};
|
|
6420
|
-
}, []);
|
|
6421
|
-
return {};
|
|
6422
|
-
};
|
|
6423
|
-
useAddProtocol.defaultProps = {
|
|
6424
|
-
mapId: undefined,
|
|
6425
|
-
};
|
|
6426
|
-
|
|
6427
|
-
var SimpleDataContext = /*#__PURE__*/React__default["default"].createContext({});
|
|
6428
|
-
var SimpleDataContextProvider = SimpleDataContext.Provider;
|
|
6429
|
-
|
|
6430
|
-
var SimpleDataProvider = function SimpleDataProvider(props) {
|
|
6431
|
-
var _useState = React.useState(null),
|
|
6432
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
6433
|
-
data = _useState2[0],
|
|
6434
|
-
setData = _useState2[1];
|
|
6435
|
-
React.useEffect(function () {
|
|
6436
|
-
if (!props.url) return;
|
|
6437
|
-
var data_promise = null;
|
|
6438
|
-
if (props.format === "json") {
|
|
6439
|
-
data_promise = d3__namespace.json(props.url);
|
|
6440
|
-
} else if (props.format === "csv") {
|
|
6441
|
-
data_promise = d3__namespace.csv(props.url);
|
|
6442
|
-
} else if (props.format === "xml") {
|
|
6443
|
-
data_promise = d3__namespace.xml(props.url);
|
|
6444
|
-
}
|
|
6445
|
-
if (data_promise) {
|
|
6446
|
-
data_promise.then(function (received_data) {
|
|
6447
|
-
if (props.format === "xml") {
|
|
6448
|
-
if (props.nodeType) {
|
|
6449
|
-
var dataTmp = [];
|
|
6450
|
-
received_data.querySelectorAll(props.nodeType).forEach(function (el) {
|
|
6451
|
-
dataTmp.push(props.formatData(el));
|
|
6452
|
-
});
|
|
6453
|
-
setData(dataTmp);
|
|
6454
|
-
}
|
|
6455
|
-
} else {
|
|
6456
|
-
if (props.data_property) {
|
|
6457
|
-
received_data = received_data[props.data_property];
|
|
6458
|
-
}
|
|
6459
|
-
if (typeof props.formatData === "function") {
|
|
6460
|
-
setData(received_data.map(props.formatData));
|
|
6461
|
-
} else {
|
|
6462
|
-
setData(received_data);
|
|
6463
|
-
}
|
|
6464
|
-
}
|
|
6465
|
-
if (typeof props.onData === "function") {
|
|
6466
|
-
props.onData();
|
|
6467
|
-
}
|
|
6468
|
-
});
|
|
6469
|
-
}
|
|
6470
|
-
}, [props.url, props]);
|
|
6471
|
-
var value = {
|
|
6472
|
-
data: data,
|
|
6473
|
-
setData: setData
|
|
6474
|
-
};
|
|
6475
|
-
return /*#__PURE__*/React__default["default"].createElement(SimpleDataContextProvider, {
|
|
6476
|
-
value: value
|
|
6477
|
-
}, props.children);
|
|
6478
|
-
};
|
|
6479
|
-
SimpleDataProvider.propTypes = {
|
|
6480
|
-
children: PropTypes__default["default"].node.isRequired
|
|
6481
|
-
};
|
|
6482
|
-
|
|
6483
|
-
var ListStyled$1 = material.styled(material.List)({
|
|
6484
|
-
marginTop: '15px',
|
|
6485
|
-
});
|
|
6486
|
-
function LayerList(props) {
|
|
6487
|
-
return React__default["default"].createElement(ListStyled$1, null, props === null || props === void 0 ? void 0 : props.children);
|
|
6488
|
-
}
|
|
6489
|
-
|
|
6490
|
-
var ListItemStyled$1 = system.styled(material.ListItem)({
|
|
6491
|
-
paddingRight: 0,
|
|
6492
|
-
paddingLeft: 0,
|
|
6493
|
-
paddingTop: 0,
|
|
6494
|
-
paddingBottom: '4px',
|
|
6495
|
-
});
|
|
6496
|
-
var ListItemIconStyled = system.styled(material.ListItemIcon)({
|
|
6497
|
-
minWidth: '30px',
|
|
6498
|
-
});
|
|
6499
|
-
var IconButtonStyled$1 = system.styled(material.IconButton)({
|
|
6500
|
-
marginRight: '0px',
|
|
6501
|
-
padding: '0px',
|
|
6502
|
-
});
|
|
6503
|
-
var CheckboxStyled$1 = system.styled(material.Checkbox)({
|
|
6504
|
-
padding: 0,
|
|
6505
|
-
marginRight: '5px',
|
|
6506
|
-
});
|
|
6507
|
-
var BoxStyled$1 = system.styled(system.Box)(function (_a) {
|
|
6508
|
-
var open = _a.open;
|
|
6509
|
-
return ({
|
|
6510
|
-
display: open ? 'block' : 'none',
|
|
6511
|
-
});
|
|
6512
|
-
});
|
|
6513
|
-
var ListStyled = system.styled(material.List)({
|
|
6514
|
-
marginLeft: '50px',
|
|
6515
|
-
});
|
|
6516
|
-
function LayerListFolder(_a) {
|
|
6517
|
-
var _b = _a.visible, visible = _b === void 0 ? true : _b, name = _a.name, children = _a.children, setVisible = _a.setVisible;
|
|
6518
|
-
var _c = React.useState(false), open = _c[0], setOpen = _c[1];
|
|
6519
|
-
var _d = React.useState(true), localVisible = _d[0], setLocalVisible = _d[1];
|
|
6520
|
-
var _visible = React.useMemo(function () {
|
|
6521
|
-
if (!visible) {
|
|
6522
|
-
return false;
|
|
6523
|
-
}
|
|
6524
|
-
return localVisible;
|
|
6525
|
-
}, [visible, localVisible]);
|
|
6526
|
-
var _children = React.useMemo(function () {
|
|
6527
|
-
if (children) {
|
|
6528
|
-
if (Array.isArray(children)) {
|
|
6529
|
-
return children.map(function (element) {
|
|
6530
|
-
return React__default["default"].cloneElement(element, {
|
|
6531
|
-
visible: _visible,
|
|
6532
|
-
});
|
|
6533
|
-
});
|
|
6534
|
-
}
|
|
6535
|
-
return React__default["default"].cloneElement(children, {
|
|
6536
|
-
visible: _visible,
|
|
6537
|
-
});
|
|
6538
|
-
}
|
|
6539
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
6540
|
-
}, [_visible]);
|
|
6541
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6542
|
-
React__default["default"].createElement(ListItemStyled$1, null,
|
|
6543
|
-
React__default["default"].createElement(ListItemIconStyled, null,
|
|
6544
|
-
React__default["default"].createElement(IconButtonStyled$1, { edge: "end", "aria-label": "open", onClick: function () { return setOpen(!open); } }, open ? React__default["default"].createElement(iconsMaterial.ExpandMore, null) : React__default["default"].createElement(iconsMaterial.KeyboardArrowRight, null)),
|
|
6545
|
-
React__default["default"].createElement(CheckboxStyled$1, { disabled: setVisible ? false : !visible, checked: setVisible ? visible : localVisible, onClick: function () {
|
|
6546
|
-
if (setVisible) {
|
|
6547
|
-
setVisible(function (val) { return !val; });
|
|
6548
|
-
}
|
|
6549
|
-
else {
|
|
6550
|
-
setLocalVisible(function (val) { return !val; });
|
|
6551
|
-
}
|
|
6552
|
-
} })),
|
|
6553
|
-
React__default["default"].createElement(material.ListItemText, { primary: name, variant: "layerlist" })),
|
|
6554
|
-
React__default["default"].createElement(BoxStyled$1, { open: open },
|
|
6555
|
-
React__default["default"].createElement(ListStyled, { disablePadding: true }, _children))));
|
|
6556
|
-
}
|
|
6557
|
-
|
|
6558
|
-
var converters = {
|
|
6559
|
-
rgba: function (c) { return "rgba(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ", ").concat(c.rgb.a, ")"); },
|
|
6560
|
-
rgb: function (c) { return "rgb(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ")"); },
|
|
6561
|
-
hex: function (c) { return c.hex; },
|
|
6562
|
-
rgba_rgb: function (c) { return c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c); },
|
|
6563
|
-
rgba_hex: function (c) { return c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c); }
|
|
6316
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
6317
|
+
}, [_visible]);
|
|
6318
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6319
|
+
React__default["default"].createElement(ListItemStyled$1, null,
|
|
6320
|
+
React__default["default"].createElement(ListItemIconStyled, null,
|
|
6321
|
+
React__default["default"].createElement(IconButtonStyled$1, { edge: "end", "aria-label": "open", onClick: function () { return setOpen(!open); } }, open ? React__default["default"].createElement(iconsMaterial.ExpandMore, null) : React__default["default"].createElement(iconsMaterial.KeyboardArrowRight, null)),
|
|
6322
|
+
React__default["default"].createElement(CheckboxStyled$1, { disabled: setVisible ? false : !visible, checked: setVisible ? visible : localVisible, onClick: function () {
|
|
6323
|
+
if (setVisible) {
|
|
6324
|
+
setVisible(function (val) { return !val; });
|
|
6325
|
+
}
|
|
6326
|
+
else {
|
|
6327
|
+
setLocalVisible(function (val) { return !val; });
|
|
6328
|
+
}
|
|
6329
|
+
} })),
|
|
6330
|
+
React__default["default"].createElement(material.ListItemText, { primary: name, variant: "layerlist" })),
|
|
6331
|
+
React__default["default"].createElement(BoxStyled$1, { open: open },
|
|
6332
|
+
React__default["default"].createElement(ListStyled$1, { disablePadding: true }, _children))));
|
|
6333
|
+
}
|
|
6334
|
+
|
|
6335
|
+
var converters = {
|
|
6336
|
+
rgba: function (c) { return "rgba(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ", ").concat(c.rgb.a, ")"); },
|
|
6337
|
+
rgb: function (c) { return "rgb(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ")"); },
|
|
6338
|
+
hex: function (c) { return c.hex; },
|
|
6339
|
+
rgba_rgb: function (c) { return c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c); },
|
|
6340
|
+
rgba_hex: function (c) { return c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c); }
|
|
6564
6341
|
};
|
|
6565
6342
|
|
|
6566
6343
|
var ColorPicker = function (_a) {
|
|
@@ -6771,26 +6548,24 @@ LayerListItemVectorLayer.defaultProps = {
|
|
|
6771
6548
|
configurable: true,
|
|
6772
6549
|
};
|
|
6773
6550
|
|
|
6774
|
-
var TuneIconButton = material.styled(material.IconButton)(
|
|
6775
|
-
marginRight: showDeleteButton ? '4px' : '1000px',
|
|
6551
|
+
var TuneIconButton = material.styled(material.IconButton)({
|
|
6776
6552
|
padding: '4px',
|
|
6777
6553
|
marginTop: '-3px',
|
|
6778
|
-
});
|
|
6554
|
+
});
|
|
6779
6555
|
var DeleteIconButton = material.styled(material.IconButton)({
|
|
6780
|
-
|
|
6781
|
-
marginTop: '-3px',
|
|
6556
|
+
marginLeft: '20px',
|
|
6782
6557
|
});
|
|
6783
6558
|
function LayerListItem(_a) {
|
|
6784
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6559
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
6785
6560
|
var layerComponent = _a.layerComponent, visible = _a.visible, type = _a.type, name = _a.name, description = _a.description, configurable = _a.configurable, setLayerState = _a.setLayerState, props = __rest(_a, ["layerComponent", "visible", "type", "name", "description", "configurable", "setLayerState"]);
|
|
6786
|
-
var
|
|
6787
|
-
var
|
|
6788
|
-
var
|
|
6561
|
+
var _p = React.useState(true), localVisible = _p[0], setLocalVisible = _p[1];
|
|
6562
|
+
var _q = React.useState(false), paintPropsFormVisible = _q[0], setPaintPropsFormVisible = _q[1];
|
|
6563
|
+
var _r = React.useState(false), showDeletionConfirmationDialog = _r[0], setShowDeletionConfirmationDialog = _r[1];
|
|
6789
6564
|
var deletedRef = React.useRef(false);
|
|
6790
6565
|
var visibleRef = React.useRef(visible);
|
|
6791
6566
|
// this state variable is used for layer components that provide a paint attribute
|
|
6792
|
-
var
|
|
6793
|
-
getDefaultPaintPropsByType(((_c = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _c === void 0 ? void 0 : _c.type) || getDefaulLayerTypeByGeometry(layerComponent.props.geojson))), paintProps =
|
|
6567
|
+
var _s = React.useState(((_b = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _b === void 0 ? void 0 : _b.paint) ||
|
|
6568
|
+
getDefaultPaintPropsByType(((_c = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _c === void 0 ? void 0 : _c.type) || getDefaulLayerTypeByGeometry(layerComponent.props.geojson))), paintProps = _s[0], setPaintProps = _s[1];
|
|
6794
6569
|
var _visible = React.useMemo(function () {
|
|
6795
6570
|
if (!visible) {
|
|
6796
6571
|
return false;
|
|
@@ -6858,42 +6633,45 @@ function LayerListItem(_a) {
|
|
|
6858
6633
|
}
|
|
6859
6634
|
return undefined;
|
|
6860
6635
|
}, [layerComponent]);
|
|
6636
|
+
var listContent = (React__default["default"].createElement(ListItemStyled, { sx: __assign({}, props.listItemSx), secondaryAction: configurable && ((_f = Object.keys(paintProps)) === null || _f === void 0 ? void 0 : _f.length) > 0 ? (React__default["default"].createElement(React__default["default"].Fragment, null, props === null || props === void 0 ? void 0 :
|
|
6637
|
+
props.buttons,
|
|
6638
|
+
React__default["default"].createElement(TuneIconButton, { edge: 'end', "aria-label": "settings", onClick: function () {
|
|
6639
|
+
setPaintPropsFormVisible(function (current) {
|
|
6640
|
+
return !current;
|
|
6641
|
+
});
|
|
6642
|
+
} },
|
|
6643
|
+
React__default["default"].createElement(iconsMaterial.Tune, null)))) : undefined },
|
|
6644
|
+
React__default["default"].createElement(CheckboxListItemIcon, null,
|
|
6645
|
+
React__default["default"].createElement(CheckboxStyled, { disabled: !visible, checked: localVisible, onClick: function () {
|
|
6646
|
+
setLocalVisible(function (val) { return !val; });
|
|
6647
|
+
} })),
|
|
6648
|
+
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description, primaryTypographyProps: { overflow: 'hidden' } })));
|
|
6861
6649
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6862
|
-
!((
|
|
6863
|
-
|
|
6864
|
-
React__default["default"].createElement(TuneIconButton, { edge: props.showDeleteButton ? false : 'end', "aria-label": "settings", onClick: function () {
|
|
6865
|
-
setPaintPropsFormVisible(function (current) {
|
|
6866
|
-
return !current;
|
|
6867
|
-
});
|
|
6868
|
-
} },
|
|
6869
|
-
React__default["default"].createElement(iconsMaterial.Tune, null)),
|
|
6870
|
-
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6871
|
-
React__default["default"].createElement(DeleteIconButton, { edge: "end", "aria-label": "delete", onClick: function () {
|
|
6872
|
-
if (typeof setLayerState === 'function') {
|
|
6873
|
-
setShowDeletionConfirmationDialog(true);
|
|
6874
|
-
}
|
|
6875
|
-
} },
|
|
6876
|
-
React__default["default"].createElement(iconsMaterial.Delete, null)),
|
|
6877
|
-
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
6878
|
-
if (typeof setLayerState === 'function') {
|
|
6879
|
-
deletedRef.current = true;
|
|
6880
|
-
setLayerState(false);
|
|
6881
|
-
setShowDeletionConfirmationDialog(false);
|
|
6882
|
-
}
|
|
6883
|
-
}, onCancel: function () {
|
|
6884
|
-
setShowDeletionConfirmationDialog(false);
|
|
6885
|
-
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" })))))) : undefined },
|
|
6886
|
-
React__default["default"].createElement(CheckboxListItemIcon, null,
|
|
6887
|
-
React__default["default"].createElement(CheckboxStyled, { disabled: !visible, checked: localVisible, onClick: function () {
|
|
6888
|
-
setLocalVisible(function (val) { return !val; });
|
|
6889
|
-
} })),
|
|
6890
|
-
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description, primaryTypographyProps: { overflow: 'hidden' } }))),
|
|
6650
|
+
props.sortable && props.layerId && !((_g = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _g === void 0 ? void 0 : _g.layers) && (React__default["default"].createElement(SortableContainer, { layerId: props.layerId }, listContent)),
|
|
6651
|
+
!props.sortable && !((_h = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _h === void 0 ? void 0 : _h.layers) && (listContent),
|
|
6891
6652
|
_layerComponent,
|
|
6892
|
-
!((
|
|
6653
|
+
!((_j = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _j === void 0 ? void 0 : _j.layers) &&
|
|
6893
6654
|
Object.keys(paintProps).length > 0 &&
|
|
6894
6655
|
configurable &&
|
|
6895
|
-
paintPropsFormVisible && (React__default["default"].createElement(
|
|
6896
|
-
|
|
6656
|
+
paintPropsFormVisible && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6657
|
+
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6658
|
+
React__default["default"].createElement(DeleteIconButton, { edge: "end", "aria-label": "delete", onClick: function () {
|
|
6659
|
+
if (typeof setLayerState === 'function') {
|
|
6660
|
+
setShowDeletionConfirmationDialog(true);
|
|
6661
|
+
}
|
|
6662
|
+
} },
|
|
6663
|
+
React__default["default"].createElement(iconsMaterial.Delete, null)),
|
|
6664
|
+
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
6665
|
+
if (typeof setLayerState === 'function') {
|
|
6666
|
+
deletedRef.current = true;
|
|
6667
|
+
setLayerState(false);
|
|
6668
|
+
setShowDeletionConfirmationDialog(false);
|
|
6669
|
+
}
|
|
6670
|
+
}, onCancel: function () {
|
|
6671
|
+
setShowDeletionConfirmationDialog(false);
|
|
6672
|
+
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" })))),
|
|
6673
|
+
React__default["default"].createElement(LayerPropertyForm, { paintProps: paintProps, setPaintProps: setPaintProps, layerType: layerType }))),
|
|
6674
|
+
((_k = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _k === void 0 ? void 0 : _k.layers) && (React__default["default"].createElement(LayerListFolder, { visible: localVisible, setVisible: setLocalVisible, name: name }, (_o = (_m = (_l = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _l === void 0 ? void 0 : _l.layers) === null || _m === void 0 ? void 0 : _m.map) === null || _o === void 0 ? void 0 : _o.call(_m, function (_el, idx) { return (React__default["default"].createElement(LayerListItemVectorLayer, { vtProps: layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props, setVtProps: setLayerState, id: '' + idx, key: '' + idx, visibleMaster: _visible })); })))));
|
|
6897
6675
|
}
|
|
6898
6676
|
LayerListItem.defaultProps = {
|
|
6899
6677
|
type: 'layer',
|
|
@@ -6902,21 +6680,464 @@ LayerListItem.defaultProps = {
|
|
|
6902
6680
|
buttons: React__default["default"].createElement(React__default["default"].Fragment, null),
|
|
6903
6681
|
};
|
|
6904
6682
|
|
|
6905
|
-
var
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6683
|
+
var sketchTools = [
|
|
6684
|
+
{ name: 'Point', mode: 'draw_point', icon: React__default["default"].createElement(ScatterPlotIcon__default["default"], null) },
|
|
6685
|
+
{ name: 'LineString', mode: 'draw_line_string', icon: React__default["default"].createElement(PolylineIcon__default["default"], null) },
|
|
6686
|
+
{ name: 'Polygon', mode: 'draw_polygon', icon: React__default["default"].createElement(PentagonIcon__default["default"], null) },
|
|
6687
|
+
];
|
|
6688
|
+
/**
|
|
6689
|
+
* Component template
|
|
6690
|
+
*
|
|
6691
|
+
*/
|
|
6692
|
+
var MlSketchTool = function (props) {
|
|
6914
6693
|
var _a, _b;
|
|
6915
|
-
var
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6694
|
+
var mapHook = useMap({
|
|
6695
|
+
mapId: props.mapId,
|
|
6696
|
+
waitForLayer: props.insertBeforeLayer,
|
|
6697
|
+
});
|
|
6698
|
+
var _c = React.useState(), hoveredGeometry = _c[0], setHoveredGeometry = _c[1];
|
|
6699
|
+
var _d = React.useState({
|
|
6700
|
+
activeGeometryIndex: undefined,
|
|
6701
|
+
selectedGeoJson: undefined,
|
|
6702
|
+
geometries: [],
|
|
6703
|
+
drawMode: undefined,
|
|
6704
|
+
}), sketchState = _d[0], setSketchState = _d[1];
|
|
6705
|
+
var buttonStyle = __assign({}, props.buttonStyleOverride);
|
|
6706
|
+
var buttonClickHandler = function (buttonDrawMode) {
|
|
6707
|
+
setSketchState(function (_state) { return ({
|
|
6708
|
+
drawMode: _state.drawMode !== buttonDrawMode ? buttonDrawMode : undefined,
|
|
6709
|
+
geometries: _state.geometries,
|
|
6710
|
+
activeGeometryIndex: undefined,
|
|
6711
|
+
selectedGeoJson: undefined,
|
|
6712
|
+
}); });
|
|
6713
|
+
};
|
|
6714
|
+
var removeGeoJson = function (geoJson) {
|
|
6715
|
+
setSketchState(function (_sketchState) {
|
|
6716
|
+
var _geometries = __spreadArray([], _sketchState.geometries, true);
|
|
6717
|
+
_geometries.splice(_geometries.indexOf(geoJson), 1);
|
|
6718
|
+
return __assign(__assign({}, _sketchState), { geometries: _geometries, activeGeometryIndex: _sketchState.activeGeometryIndex
|
|
6719
|
+
? _sketchState.activeGeometryIndex - 1
|
|
6720
|
+
: undefined });
|
|
6721
|
+
});
|
|
6722
|
+
};
|
|
6723
|
+
var SketchToolButtons = function () {
|
|
6724
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, sketchTools.map(function (el) {
|
|
6725
|
+
var stateColor = function (theme) {
|
|
6726
|
+
if (sketchState.drawMode === el.mode) {
|
|
6727
|
+
return theme.palette.primary.main;
|
|
6728
|
+
}
|
|
6729
|
+
else {
|
|
6730
|
+
return theme.palette.navigation.navColor;
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6733
|
+
var stateIconColor = function (theme) {
|
|
6734
|
+
if (sketchState.drawMode !== el.mode) {
|
|
6735
|
+
return theme.palette.primary.main;
|
|
6736
|
+
}
|
|
6737
|
+
else {
|
|
6738
|
+
return theme.palette.navigation.navColor;
|
|
6739
|
+
}
|
|
6740
|
+
};
|
|
6741
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6742
|
+
React__default["default"].createElement(Tooltip__default["default"], { title: el.name },
|
|
6743
|
+
React__default["default"].createElement(material.Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
6744
|
+
backgroundColor: stateColor,
|
|
6745
|
+
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
6746
|
+
})));
|
|
6747
|
+
};
|
|
6748
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6749
|
+
React__default["default"].createElement(system.Box, { sx: {
|
|
6750
|
+
zIndex: 104,
|
|
6751
|
+
} },
|
|
6752
|
+
React__default["default"].createElement(ButtonGroup__default["default"], null,
|
|
6753
|
+
React__default["default"].createElement(SketchToolButtons, null))),
|
|
6754
|
+
sketchState.drawMode && (React__default["default"].createElement(MlFeatureEditor, { mode: sketchState.drawMode, geojson: sketchState.selectedGeoJson, onChange: function (feature) {
|
|
6755
|
+
if (!(feature === null || feature === void 0 ? void 0 : feature[0]))
|
|
6756
|
+
return;
|
|
6757
|
+
setSketchState(function (_sketchState) {
|
|
6758
|
+
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
6759
|
+
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
6760
|
+
var tempFeature = feature[0];
|
|
6761
|
+
tempFeature.properties.id = tempFeature.id;
|
|
6762
|
+
_sketchState.activeGeometryIndex = _geometries.length;
|
|
6763
|
+
_geometries.push(tempFeature);
|
|
6764
|
+
}
|
|
6765
|
+
else {
|
|
6766
|
+
_geometries[_sketchState.activeGeometryIndex] = feature[0];
|
|
6767
|
+
}
|
|
6768
|
+
return __assign(__assign({}, _sketchState), { geometries: _geometries });
|
|
6769
|
+
});
|
|
6770
|
+
}, onFinish: function () {
|
|
6771
|
+
setSketchState(function (_sketchState) { return (__assign(__assign({}, _sketchState), { drawMode: undefined, activeGeometryIndex: undefined, selectedGeoJson: undefined })); });
|
|
6772
|
+
} })),
|
|
6773
|
+
React__default["default"].createElement(List__default["default"], { sx: { zIndex: 105 } },
|
|
6774
|
+
sketchState.geometries.map(function (el) { return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6775
|
+
React__default["default"].createElement(system.Box, { key: el.id, sx: { display: 'flex', flexDirection: 'column' } },
|
|
6776
|
+
React__default["default"].createElement("br", null),
|
|
6777
|
+
React__default["default"].createElement(system.Box, { flexDirection: 'row', sx: {
|
|
6778
|
+
'&:hover': {
|
|
6779
|
+
backgroundColor: 'rgb(177, 177, 177, 0.2)',
|
|
6780
|
+
},
|
|
6781
|
+
}, onMouseOver: function () {
|
|
6782
|
+
setHoveredGeometry(el);
|
|
6783
|
+
}, onMouseLeave: function () {
|
|
6784
|
+
setHoveredGeometry(undefined);
|
|
6785
|
+
} },
|
|
6786
|
+
React__default["default"].createElement(LayerListItem, { listItemSx: buttonStyle, configurable: true, layerComponent: React__default["default"].createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: el, layerId: String(el.id) }), type: 'layer', name: String(el.id), description: el.geometry.type }),
|
|
6787
|
+
React__default["default"].createElement(system.Box, { sx: {
|
|
6788
|
+
padding: '3px 30px',
|
|
6789
|
+
} },
|
|
6790
|
+
React__default["default"].createElement(ButtonGroup__default["default"], { size: "small" },
|
|
6791
|
+
React__default["default"].createElement(material.Button, { onClick: function () {
|
|
6792
|
+
var _a;
|
|
6793
|
+
(_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setCenter(el.geometry.type === 'Point'
|
|
6794
|
+
? el.geometry.coordinates
|
|
6795
|
+
: turf__namespace.centerOfMass(el).geometry.coordinates);
|
|
6796
|
+
} },
|
|
6797
|
+
React__default["default"].createElement(GpsFixedIcon__default["default"], null)),
|
|
6798
|
+
React__default["default"].createElement(material.Button, { sx: buttonStyle, onClick: function () {
|
|
6799
|
+
setSketchState(function (_sketchState) { return (__assign(__assign({}, _sketchState), { selectedGeoJson: el, activeGeometryIndex: _sketchState.geometries.indexOf(el), drawMode: 'simple_select' })); });
|
|
6800
|
+
} },
|
|
6801
|
+
React__default["default"].createElement(EditIcon__default["default"], null)),
|
|
6802
|
+
React__default["default"].createElement(material.Button, { sx: buttonStyle, onClick: function () {
|
|
6803
|
+
removeGeoJson(el);
|
|
6804
|
+
setHoveredGeometry(undefined);
|
|
6805
|
+
} },
|
|
6806
|
+
React__default["default"].createElement(DeleteIcon__default["default"], null)))))))); }),
|
|
6807
|
+
hoveredGeometry && (React__default["default"].createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: { type: 'FeatureCollection', features: [hoveredGeometry] }, type: 'line', layerId: 'highlightBorder', paint: {
|
|
6808
|
+
'line-color': '#dd9900',
|
|
6809
|
+
'line-opacity': 0.4,
|
|
6810
|
+
'line-width': 10,
|
|
6811
|
+
} }))),
|
|
6812
|
+
sketchState.drawMode === 'simple_select' && (React__default["default"].createElement(material.Typography, { sx: { fontSize: '0.6em' } },
|
|
6813
|
+
"Edit ", (_b = (_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.geometry) === null || _b === void 0 ? void 0 :
|
|
6814
|
+
_b.type))));
|
|
6815
|
+
};
|
|
6816
|
+
MlSketchTool.defaultProps = {
|
|
6817
|
+
mapId: undefined,
|
|
6818
|
+
buttonStyleOverride: {},
|
|
6819
|
+
};
|
|
6820
|
+
|
|
6821
|
+
/**
|
|
6822
|
+
* Component template
|
|
6823
|
+
*
|
|
6824
|
+
*/
|
|
6825
|
+
var useCameraFollowPath = function (props) {
|
|
6826
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
6827
|
+
// without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
|
|
6828
|
+
var initializedRef = React.useRef(false);
|
|
6829
|
+
var pause = React.useRef(props.pause);
|
|
6830
|
+
var zoom = React.useRef(props.zoom);
|
|
6831
|
+
var pitch = React.useRef(props.pitch);
|
|
6832
|
+
var step = React.useRef(1);
|
|
6833
|
+
var speed = React.useRef(props.speed);
|
|
6834
|
+
var timeoutId = React.useRef();
|
|
6835
|
+
var kmPerStep = props.kmPerStep || 0.01;
|
|
6836
|
+
var routeDistance = turf__namespace.lineDistance(props.route);
|
|
6837
|
+
var stepDuration = props.stepDuration || 70;
|
|
6838
|
+
var mapHook = useMap({
|
|
6839
|
+
mapId: props.mapId,
|
|
6840
|
+
waitForLayer: props.insertBeforeLayer,
|
|
6841
|
+
});
|
|
6842
|
+
React.useEffect(function () {
|
|
6843
|
+
pause.current = props.pause;
|
|
6844
|
+
if (!pause.current) {
|
|
6845
|
+
play();
|
|
6846
|
+
}
|
|
6847
|
+
}, [props.pause]);
|
|
6848
|
+
React.useEffect(function () {
|
|
6849
|
+
if (!mapHook.map)
|
|
6850
|
+
return;
|
|
6851
|
+
zoom.current = props.zoom;
|
|
6852
|
+
if (typeof zoom.current !== 'undefined' && mapHook.map.map.getZoom() !== zoom.current) {
|
|
6853
|
+
mapHook.map.map.setZoom(zoom.current);
|
|
6854
|
+
}
|
|
6855
|
+
}, [mapHook.map, props.zoom]);
|
|
6856
|
+
React.useEffect(function () {
|
|
6857
|
+
if (!mapHook.map)
|
|
6858
|
+
return;
|
|
6859
|
+
pitch.current = props.pitch;
|
|
6860
|
+
if (typeof pitch.current !== 'undefined' && pitch.current !== mapHook.map.map.getPitch()) {
|
|
6861
|
+
mapHook.map.map.setPitch(pitch.current);
|
|
6862
|
+
}
|
|
6863
|
+
}, [mapHook.map, props.pitch]);
|
|
6864
|
+
React.useEffect(function () {
|
|
6865
|
+
speed.current = props.speed;
|
|
6866
|
+
}, [props.speed]);
|
|
6867
|
+
var disableInteractivity = React.useCallback(function () {
|
|
6868
|
+
if (!mapHook.map)
|
|
6869
|
+
return;
|
|
6870
|
+
mapHook.map.map['scrollZoom'].disable();
|
|
6871
|
+
mapHook.map.map['boxZoom'].disable();
|
|
6872
|
+
mapHook.map.map['dragRotate'].disable();
|
|
6873
|
+
mapHook.map.map['dragPan'].disable();
|
|
6874
|
+
mapHook.map.map['keyboard'].disable();
|
|
6875
|
+
mapHook.map.map['doubleClickZoom'].disable();
|
|
6876
|
+
mapHook.map.map['touchZoomRotate'].disable();
|
|
6877
|
+
}, [mapHook.map]);
|
|
6878
|
+
var enableInteractivity = React.useCallback(function () {
|
|
6879
|
+
if (!mapHook.map)
|
|
6880
|
+
return;
|
|
6881
|
+
mapHook.map.map['scrollZoom'].enable();
|
|
6882
|
+
mapHook.map.map['boxZoom'].enable();
|
|
6883
|
+
mapHook.map.map['dragRotate'].enable();
|
|
6884
|
+
mapHook.map.map['dragPan'].enable();
|
|
6885
|
+
mapHook.map.map['keyboard'].enable();
|
|
6886
|
+
mapHook.map.map['doubleClickZoom'].enable();
|
|
6887
|
+
mapHook.map.map['touchZoomRotate'].enable();
|
|
6888
|
+
}, [mapHook.map]);
|
|
6889
|
+
function centerRoute() {
|
|
6890
|
+
if (!mapHook.map || !props.route)
|
|
6891
|
+
return;
|
|
6892
|
+
var bbox = turf__namespace.bbox(props.route);
|
|
6893
|
+
var bounds;
|
|
6894
|
+
if (bbox && bbox.length > 3) {
|
|
6895
|
+
bounds = [
|
|
6896
|
+
[bbox[0], bbox[1]],
|
|
6897
|
+
[bbox[2], bbox[3]],
|
|
6898
|
+
];
|
|
6899
|
+
mapHook.map.map.fitBounds(bounds, { padding: 100 });
|
|
6900
|
+
}
|
|
6901
|
+
}
|
|
6902
|
+
function play() {
|
|
6903
|
+
if (!mapHook.map)
|
|
6904
|
+
return;
|
|
6905
|
+
if (!pause.current) {
|
|
6906
|
+
disableInteractivity();
|
|
6907
|
+
if (typeof zoom.current !== 'undefined' && mapHook.map.map.getZoom() !== zoom.current) {
|
|
6908
|
+
mapHook.map.map.setZoom(zoom.current);
|
|
6909
|
+
}
|
|
6910
|
+
var alongRoutelati = turf__namespace.along(props.route, step.current * kmPerStep).geometry
|
|
6911
|
+
.coordinates;
|
|
6912
|
+
if (step.current * kmPerStep < routeDistance) {
|
|
6913
|
+
mapHook.map.map.easeTo({
|
|
6914
|
+
center: alongRoutelati,
|
|
6915
|
+
bearing: turf__namespace.bearing(turf__namespace.point([mapHook.map.map.getCenter().lng, mapHook.map.map.getCenter().lat]), turf__namespace.point(alongRoutelati)),
|
|
6916
|
+
duration: stepDuration,
|
|
6917
|
+
essential: true,
|
|
6918
|
+
});
|
|
6919
|
+
if (typeof speed.current !== 'undefined') {
|
|
6920
|
+
step.current = step.current + speed.current;
|
|
6921
|
+
}
|
|
6922
|
+
else {
|
|
6923
|
+
step.current++;
|
|
6924
|
+
}
|
|
6925
|
+
console.log('PAN MOVE');
|
|
6926
|
+
setTimeout(function () {
|
|
6927
|
+
play();
|
|
6928
|
+
}, 100);
|
|
6929
|
+
}
|
|
6930
|
+
else {
|
|
6931
|
+
mapHook.map.map.setPitch(0);
|
|
6932
|
+
centerRoute();
|
|
6933
|
+
enableInteractivity();
|
|
6934
|
+
console.log('ENABLE CONTROLS');
|
|
6935
|
+
step.current = 1;
|
|
6936
|
+
}
|
|
6937
|
+
}
|
|
6938
|
+
else {
|
|
6939
|
+
enableInteractivity();
|
|
6940
|
+
}
|
|
6941
|
+
}
|
|
6942
|
+
function reset() {
|
|
6943
|
+
if (!mapHook.map)
|
|
6944
|
+
return;
|
|
6945
|
+
centerRoute();
|
|
6946
|
+
enableInteractivity();
|
|
6947
|
+
step.current = 1;
|
|
6948
|
+
}
|
|
6949
|
+
React.useEffect(function () {
|
|
6950
|
+
if (!mapHook.map || initializedRef.current)
|
|
6951
|
+
return;
|
|
6952
|
+
initializedRef.current = true;
|
|
6953
|
+
centerRoute();
|
|
6954
|
+
}, [mapHook.map]);
|
|
6955
|
+
React.useEffect(function () {
|
|
6956
|
+
return function () {
|
|
6957
|
+
if (timeoutId.current) {
|
|
6958
|
+
clearTimeout(timeoutId.current);
|
|
6959
|
+
}
|
|
6960
|
+
};
|
|
6961
|
+
}, []);
|
|
6962
|
+
return {
|
|
6963
|
+
play: play,
|
|
6964
|
+
reset: reset,
|
|
6965
|
+
};
|
|
6966
|
+
};
|
|
6967
|
+
useCameraFollowPath.defaultProps = {
|
|
6968
|
+
mapId: undefined,
|
|
6969
|
+
zoom: 18,
|
|
6970
|
+
};
|
|
6971
|
+
|
|
6972
|
+
function useLayerFilter(props) {
|
|
6973
|
+
var mapHook = useMap({ mapId: props.mapId });
|
|
6974
|
+
React.useEffect(function () {
|
|
6975
|
+
if (!mapHook.map || !props.layerId || !props.filter)
|
|
6976
|
+
return;
|
|
6977
|
+
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
6978
|
+
var _layerId_1 = props.layerId;
|
|
6979
|
+
mapHook.map.map.setFilter(_layerId_1, props.filter);
|
|
6980
|
+
return function () {
|
|
6981
|
+
if (mapHook.map) {
|
|
6982
|
+
mapHook.map.map.setFilter(_layerId_1, null);
|
|
6983
|
+
}
|
|
6984
|
+
};
|
|
6985
|
+
}
|
|
6986
|
+
return;
|
|
6987
|
+
}, [props, mapHook.map]);
|
|
6988
|
+
return {};
|
|
6989
|
+
}
|
|
6990
|
+
|
|
6991
|
+
var touchEquivalents = {
|
|
6992
|
+
mousedown: 'touchstart',
|
|
6993
|
+
mouseup: 'touchend',
|
|
6994
|
+
mousemove: 'touchmove'
|
|
6995
|
+
};
|
|
6996
|
+
var touchEquivalentsKeys = Object.keys(touchEquivalents);
|
|
6997
|
+
function useLayerEvent(props) {
|
|
6998
|
+
var mapState = useMapState({
|
|
6999
|
+
mapId: props.mapId,
|
|
7000
|
+
watch: {
|
|
7001
|
+
layers: true
|
|
7002
|
+
}
|
|
7003
|
+
});
|
|
7004
|
+
var mapHook = useMap({
|
|
7005
|
+
mapId: props.mapId
|
|
7006
|
+
});
|
|
7007
|
+
React.useEffect(function () {
|
|
7008
|
+
if (!mapHook.map) return true;
|
|
7009
|
+
if (typeof props.condition !== 'undefined' && props.condition === false) return;
|
|
7010
|
+
//console.log('useLayerEvent');
|
|
7011
|
+
//console.log(mapState);
|
|
7012
|
+
|
|
7013
|
+
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
7014
|
+
//console.log("layer avail");
|
|
7015
|
+
var _event = props.event;
|
|
7016
|
+
var _layerId = props.layerId;
|
|
7017
|
+
var _eventHandler = props.eventHandler;
|
|
7018
|
+
|
|
7019
|
+
//console.log(_event);
|
|
7020
|
+
mapHook.map.on(_event, _layerId, _eventHandler, mapHook.componentId);
|
|
7021
|
+
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
7022
|
+
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
7023
|
+
mapHook.map.on(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
return function () {
|
|
7027
|
+
mapHook.map.off(_event, _layerId, _eventHandler);
|
|
7028
|
+
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
7029
|
+
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
7030
|
+
mapHook.map.off(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
7031
|
+
}
|
|
7032
|
+
}
|
|
7033
|
+
};
|
|
7034
|
+
}
|
|
7035
|
+
}, [props, mapState, mapHook.map]);
|
|
7036
|
+
return {};
|
|
7037
|
+
}
|
|
7038
|
+
|
|
7039
|
+
var useLayerContext = function () {
|
|
7040
|
+
var layerContext = React.useContext(LayerContext);
|
|
7041
|
+
return layerContext;
|
|
7042
|
+
};
|
|
7043
|
+
|
|
7044
|
+
/**
|
|
7045
|
+
* Enables the use of custom protocols (basically custom tile load functions) in the maplibre-gl-js library.
|
|
7046
|
+
*
|
|
7047
|
+
*/
|
|
7048
|
+
var useAddProtocol = function (props) {
|
|
7049
|
+
React.useEffect(function () {
|
|
7050
|
+
if (!props.protocol || typeof props.handler !== 'function')
|
|
7051
|
+
return;
|
|
7052
|
+
maplibregl__default["default"].addProtocol(props.protocol, props.handler);
|
|
7053
|
+
return function () {
|
|
7054
|
+
maplibregl__default["default"].removeProtocol(props.protocol);
|
|
7055
|
+
};
|
|
7056
|
+
}, []);
|
|
7057
|
+
return {};
|
|
7058
|
+
};
|
|
7059
|
+
useAddProtocol.defaultProps = {
|
|
7060
|
+
mapId: undefined,
|
|
7061
|
+
};
|
|
7062
|
+
|
|
7063
|
+
var SimpleDataContext = /*#__PURE__*/React__default["default"].createContext({});
|
|
7064
|
+
var SimpleDataContextProvider = SimpleDataContext.Provider;
|
|
7065
|
+
|
|
7066
|
+
var SimpleDataProvider = function SimpleDataProvider(props) {
|
|
7067
|
+
var _useState = React.useState(null),
|
|
7068
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7069
|
+
data = _useState2[0],
|
|
7070
|
+
setData = _useState2[1];
|
|
7071
|
+
React.useEffect(function () {
|
|
7072
|
+
if (!props.url) return;
|
|
7073
|
+
var data_promise = null;
|
|
7074
|
+
if (props.format === "json") {
|
|
7075
|
+
data_promise = d3__namespace.json(props.url);
|
|
7076
|
+
} else if (props.format === "csv") {
|
|
7077
|
+
data_promise = d3__namespace.csv(props.url);
|
|
7078
|
+
} else if (props.format === "xml") {
|
|
7079
|
+
data_promise = d3__namespace.xml(props.url);
|
|
7080
|
+
}
|
|
7081
|
+
if (data_promise) {
|
|
7082
|
+
data_promise.then(function (received_data) {
|
|
7083
|
+
if (props.format === "xml") {
|
|
7084
|
+
if (props.nodeType) {
|
|
7085
|
+
var dataTmp = [];
|
|
7086
|
+
received_data.querySelectorAll(props.nodeType).forEach(function (el) {
|
|
7087
|
+
dataTmp.push(props.formatData(el));
|
|
7088
|
+
});
|
|
7089
|
+
setData(dataTmp);
|
|
7090
|
+
}
|
|
7091
|
+
} else {
|
|
7092
|
+
if (props.data_property) {
|
|
7093
|
+
received_data = received_data[props.data_property];
|
|
7094
|
+
}
|
|
7095
|
+
if (typeof props.formatData === "function") {
|
|
7096
|
+
setData(received_data.map(props.formatData));
|
|
7097
|
+
} else {
|
|
7098
|
+
setData(received_data);
|
|
7099
|
+
}
|
|
7100
|
+
}
|
|
7101
|
+
if (typeof props.onData === "function") {
|
|
7102
|
+
props.onData();
|
|
7103
|
+
}
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7106
|
+
}, [props.url, props]);
|
|
7107
|
+
var value = {
|
|
7108
|
+
data: data,
|
|
7109
|
+
setData: setData
|
|
7110
|
+
};
|
|
7111
|
+
return /*#__PURE__*/React__default["default"].createElement(SimpleDataContextProvider, {
|
|
7112
|
+
value: value
|
|
7113
|
+
}, props.children);
|
|
7114
|
+
};
|
|
7115
|
+
SimpleDataProvider.propTypes = {
|
|
7116
|
+
children: PropTypes__default["default"].node.isRequired
|
|
7117
|
+
};
|
|
7118
|
+
|
|
7119
|
+
var ListStyled = material.styled(material.List)({
|
|
7120
|
+
marginTop: '15px',
|
|
7121
|
+
});
|
|
7122
|
+
function LayerList(props) {
|
|
7123
|
+
return React__default["default"].createElement(ListStyled, null, props === null || props === void 0 ? void 0 : props.children);
|
|
7124
|
+
}
|
|
7125
|
+
|
|
7126
|
+
var IconButtonStyled = material.styled(material.IconButton)({
|
|
7127
|
+
padding: '4px',
|
|
7128
|
+
marginTop: '-3px',
|
|
7129
|
+
background: 'none',
|
|
7130
|
+
'&:hover': {
|
|
7131
|
+
background: 'none',
|
|
7132
|
+
},
|
|
7133
|
+
});
|
|
7134
|
+
function LayerListItemFactory(props) {
|
|
7135
|
+
var _a, _b;
|
|
7136
|
+
var layerContext = useLayerContext();
|
|
7137
|
+
var orderLayers = React.useMemo(function () {
|
|
7138
|
+
var layerIds = __spreadArray(__spreadArray([
|
|
7139
|
+
'order-background'
|
|
7140
|
+
], __spreadArray([], layerContext.layers, true).map(function (_el, idx) { return 'content_order_' + idx; }), true), [
|
|
6920
7141
|
'order-labels',
|
|
6921
7142
|
], false);
|
|
6922
7143
|
return layerIds.reverse();
|
|
@@ -6933,77 +7154,95 @@ function LayerListItemFactory(props) {
|
|
|
6933
7154
|
return props.setLayers;
|
|
6934
7155
|
return layerContext.setLayers;
|
|
6935
7156
|
}, [props.setLayers, layerContext.setLayers]);
|
|
7157
|
+
var pointerSensor = core.useSensor(core.PointerSensor, {
|
|
7158
|
+
activationConstraint: {
|
|
7159
|
+
distance: 5,
|
|
7160
|
+
},
|
|
7161
|
+
});
|
|
7162
|
+
var mouseSensor = core.useSensor(core.MouseSensor, {
|
|
7163
|
+
activationConstraint: {
|
|
7164
|
+
distance: 5,
|
|
7165
|
+
},
|
|
7166
|
+
});
|
|
7167
|
+
var sensors = core.useSensors(mouseSensor, pointerSensor);
|
|
7168
|
+
function dragEnd(event) {
|
|
7169
|
+
var _a, _b, _c;
|
|
7170
|
+
var dragLayerId = event.active.id;
|
|
7171
|
+
var dragLayerNewPosition = (_c = (_b = (_a = event.over) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.sortable.index;
|
|
7172
|
+
layerContext.moveLayer(String(dragLayerId), function () { return dragLayerNewPosition; });
|
|
7173
|
+
}
|
|
6936
7174
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6937
7175
|
React__default["default"].createElement(MlOrderLayers, { layerIds: orderLayers, insertBeforeLayer: "_background" }),
|
|
6938
7176
|
((_a = layerContext === null || layerContext === void 0 ? void 0 : layerContext.symbolLayers) === null || _a === void 0 ? void 0 : _a.length) > 0 && (React__default["default"].createElement(LayerListItem, { key: 'background_labels', layerComponent: React__default["default"].createElement(MlVectorTileLayer, __assign({}, layerContext.vtLayerConfig, { layers: layerContext.symbolLayers, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'order-labels' })), setLayerState: function (state) {
|
|
6939
7177
|
return layerContext.setSymbolLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
6940
7178
|
}, visible: true, configurable: true, type: "layer", name: "Labels" })),
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
layerContext.
|
|
7006
|
-
|
|
7179
|
+
React__default["default"].createElement(core.DndContext, { collisionDetection: core.closestCenter, sensors: sensors, onDragEnd: function (event) { return dragEnd(event); }, modifiers: [modifiers.restrictToVerticalAxis] },
|
|
7180
|
+
React__default["default"].createElement(sortable.SortableContext, { items: layers, strategy: sortable.verticalListSortingStrategy },
|
|
7181
|
+
__spreadArray([], layers, true).map(function (layer, idx) {
|
|
7182
|
+
var _a, _b;
|
|
7183
|
+
if (!(layer === null || layer === void 0 ? void 0 : layer.id))
|
|
7184
|
+
return null;
|
|
7185
|
+
switch (layer.type) {
|
|
7186
|
+
case 'geojson':
|
|
7187
|
+
return (React__default["default"].createElement(LayerListItem, { key: layer.id, layerId: layer.id, sortable: props.sortable, name: (layer === null || layer === void 0 ? void 0 : layer.name) || ((_a = layer === null || layer === void 0 ? void 0 : layer.config) === null || _a === void 0 ? void 0 : _a.type) + ' layer' || 'unnamed layer', layerComponent: React__default["default"].createElement(MlGeoJsonLayer, __assign({}, layer.config, { mapId: props === null || props === void 0 ? void 0 : props.mapId, layerId: layer.id, insertBeforeLayer: 'content_order_' + (layers.length - 1 - idx) })), buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7188
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === layers.length - 1, onClick: function () {
|
|
7189
|
+
layerContext.moveDown(layer.id || '');
|
|
7190
|
+
} },
|
|
7191
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleDown, null)),
|
|
7192
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === 0, onClick: function () {
|
|
7193
|
+
layerContext.moveUp(layer.id || '');
|
|
7194
|
+
} },
|
|
7195
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleUp, null))), setLayerState: function (layerConfig) {
|
|
7196
|
+
return setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7197
|
+
var _layers = __spreadArray([], current, true);
|
|
7198
|
+
if (layerConfig === false) {
|
|
7199
|
+
_layers.splice(idx, 1);
|
|
7200
|
+
}
|
|
7201
|
+
else {
|
|
7202
|
+
_layers[idx].config = layerConfig;
|
|
7203
|
+
}
|
|
7204
|
+
return _layers;
|
|
7205
|
+
});
|
|
7206
|
+
}, configurable: true, showDeleteButton: true }));
|
|
7207
|
+
case 'wms':
|
|
7208
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7209
|
+
React__default["default"].createElement(MlWmsLoader, __assign({}, layer.config, { key: layer.id, layerId: layer.id, sortable: props.sortable, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'content_order_' + (layers.length - 1 - idx), onConfigChange: function (layerConfig) {
|
|
7210
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7211
|
+
var _layers = __spreadArray([], current, true);
|
|
7212
|
+
if (layerConfig === false) {
|
|
7213
|
+
_layers.splice(idx, 1);
|
|
7214
|
+
}
|
|
7215
|
+
else {
|
|
7216
|
+
_layers[idx].config.config = layerConfig;
|
|
7217
|
+
}
|
|
7218
|
+
return _layers;
|
|
7219
|
+
});
|
|
7220
|
+
}, featureInfoActive: ((_b = layer === null || layer === void 0 ? void 0 : layer.config) === null || _b === void 0 ? void 0 : _b.featureInfoActive) || false, setFeatureInfoActive: function (updateFunction) {
|
|
7221
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7222
|
+
var _a;
|
|
7223
|
+
var _layers = __spreadArray([], current, true);
|
|
7224
|
+
if (typeof updateFunction === 'function') {
|
|
7225
|
+
_layers[idx].config.featureInfoActive =
|
|
7226
|
+
updateFunction(((_a = _layers[idx].config) === null || _a === void 0 ? void 0 : _a.featureInfoActive) || false);
|
|
7227
|
+
}
|
|
7228
|
+
return _layers;
|
|
7229
|
+
});
|
|
7230
|
+
}, showDeleteButton: true, buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7231
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === layers.length - 1, onClick: function () {
|
|
7232
|
+
layerContext.moveDown(layer.id || '');
|
|
7233
|
+
} },
|
|
7234
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleDown, null)),
|
|
7235
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === 0, onClick: function () {
|
|
7236
|
+
layerContext.moveUp(layer.id || '');
|
|
7237
|
+
} },
|
|
7238
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleUp, null))) }))));
|
|
7239
|
+
default:
|
|
7240
|
+
return null;
|
|
7241
|
+
}
|
|
7242
|
+
}),
|
|
7243
|
+
((_b = layerContext === null || layerContext === void 0 ? void 0 : layerContext.backgroundLayers) === null || _b === void 0 ? void 0 : _b.length) > 0 && (React__default["default"].createElement(LayerListItem, { key: 'background_geometry', layerComponent: React__default["default"].createElement(MlVectorTileLayer, __assign({}, layerContext.vtLayerConfig, { layers: layerContext.backgroundLayers, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'order-background' })), setLayerState: function (state) {
|
|
7244
|
+
layerContext.setBackgroundLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
7245
|
+
}, visible: true, configurable: true, type: "layer", name: "Background" }))))));
|
|
7007
7246
|
}
|
|
7008
7247
|
LayerListItemFactory.defaultProps = {
|
|
7009
7248
|
mapId: undefined,
|
|
@@ -7125,7 +7364,8 @@ function TopToolbar(props) {
|
|
|
7125
7364
|
minHeight: '62px',
|
|
7126
7365
|
position: 'absolute',
|
|
7127
7366
|
zIndex: 1300,
|
|
7128
|
-
|
|
7367
|
+
top: 0,
|
|
7368
|
+
} },
|
|
7129
7369
|
React__namespace.createElement(Toolbar__default["default"], { disableGutters: true },
|
|
7130
7370
|
props.logo || (React__namespace.createElement(React__namespace.Fragment, null,
|
|
7131
7371
|
React__namespace.createElement(Box__default["default"], { sx: {
|
|
@@ -20177,6 +20417,7 @@ exports.MlOsmLayer = MlOsmLayer;
|
|
|
20177
20417
|
exports.MlPdfPreview = PdfPreview;
|
|
20178
20418
|
exports.MlScaleReference = MlScaleReference;
|
|
20179
20419
|
exports.MlShareMapState = MlShareMapState;
|
|
20420
|
+
exports.MlSketchTool = MlSketchTool;
|
|
20180
20421
|
exports.MlSpatialElevationProfile = MlSpatialElevationProfile;
|
|
20181
20422
|
exports.MlTemporalController = MlTemporalController;
|
|
20182
20423
|
exports.MlTerrainLayer = MlTerrainLayer;
|