@mapcomponents/react-maplibre 0.1.86 → 0.1.88
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 +21 -0
- 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.stories.d.ts +2 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +8 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +2 -0
- package/dist/components/MlLayer/MlLayer.d.ts +3 -2
- 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 +2 -1
- package/dist/components/MlTemporalController/MlTemporalController.stories.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +2 -0
- package/dist/contexts/LayerContext.d.ts +16 -2
- package/dist/hooks/useAddImage/useaddImage.cy.d.ts +1 -0
- package/dist/hooks/useAddProtocol/useAddProtocol.stories.d.ts +9 -1
- package/dist/hooks/useFitLayerBounds.d.ts +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1552 -575
- package/dist/index.esm.js.map +1 -1
- package/dist/omt_styles/bright.d.ts +2495 -0
- package/dist/protocol_handlers/csv.d.ts +8 -0
- package/dist/protocol_handlers/mbtiles.d.ts +2 -2
- package/dist/protocol_handlers/osm.d.ts +11 -0
- package/dist/protocol_handlers/topojson.d.ts +9 -0
- package/dist/protocol_handlers/utils/getProtocolData.d.ts +1 -0
- package/dist/protocol_handlers/utils/protocolPathParser.d.ts +7 -0
- package/dist/protocol_handlers/xml.d.ts +10 -0
- package/dist/ui_components/AddLayerButton/AddLayerButton.d.ts +5 -0
- package/dist/ui_components/AddLayerButton/AddLayerPopup.d.ts +1 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/LayerTypeForm.d.ts +1 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/MbtilesLayerForm.d.ts +13 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/ProtocolHandlerLayerForm.d.ts +10 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/WmsLayerForm.d.ts +2 -1
- package/dist/ui_components/AddLayerButton/LayerConfigForms/utils/CSVOptionsFomular.d.ts +6 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/utils/MbtilesLayerPropFormular.d.ts +7 -0
- package/dist/ui_components/AddLayerButton/LayerConfigForms/utils/OsmOptionsFomular.d.ts +6 -0
- package/dist/ui_components/DemoDescriptions.d.ts +12 -0
- package/dist/ui_components/LayerList/LayerListItem.d.ts +2 -0
- package/dist/ui_components/LayerList/LayerListItemFactory.d.ts +3 -0
- package/dist/ui_components/LayerList/util/SortableContainer.d.ts +7 -0
- package/package.json +9 -1
package/dist/index.esm.js
CHANGED
|
@@ -42,17 +42,36 @@ var DialogActions = require('@mui/material/DialogActions');
|
|
|
42
42
|
var DialogContent = require('@mui/material/DialogContent');
|
|
43
43
|
var DialogContentText = require('@mui/material/DialogContentText');
|
|
44
44
|
var DialogTitle = require('@mui/material/DialogTitle');
|
|
45
|
+
var sortable = require('@dnd-kit/sortable');
|
|
46
|
+
var utilities = require('@dnd-kit/utilities');
|
|
45
47
|
var PlayArrowIcon = require('@mui/icons-material/PlayArrow');
|
|
46
48
|
var PauseIcon = require('@mui/icons-material/Pause');
|
|
47
49
|
var StopIcon = require('@mui/icons-material/Stop');
|
|
48
50
|
var FastForwardIcon = require('@mui/icons-material/FastForward');
|
|
49
51
|
var FastRewindIcon = require('@mui/icons-material/FastRewind');
|
|
50
|
-
var
|
|
52
|
+
var PentagonIcon = require('@mui/icons-material/Pentagon');
|
|
51
53
|
var system = require('@mui/system');
|
|
54
|
+
var EditIcon = require('@mui/icons-material/Edit');
|
|
55
|
+
var Tooltip = require('@mui/material/Tooltip');
|
|
52
56
|
var reactColor = require('react-color');
|
|
53
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');
|
|
54
63
|
var PlaylistAddIcon = require('@mui/icons-material/PlaylistAdd');
|
|
55
64
|
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
|
|
65
|
+
var AddBoxIcon = require('@mui/icons-material/AddBox');
|
|
66
|
+
var IndeterminateCheckBoxIcon = require('@mui/icons-material/IndeterminateCheckBox');
|
|
67
|
+
var csv2geojson = require('csv2geojson');
|
|
68
|
+
var topojsonClient = require('topojson-client');
|
|
69
|
+
var osm2geojson = require('osm2geojson-lite');
|
|
70
|
+
var externParser = require('@tmcw/togeojson');
|
|
71
|
+
var initSqlJs = require('sql.js');
|
|
72
|
+
var pako = require('pako');
|
|
73
|
+
var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
|
|
74
|
+
var KeyboardArrowUpIcon = require('@mui/icons-material/KeyboardArrowUp');
|
|
56
75
|
var AppBar = require('@mui/material/AppBar');
|
|
57
76
|
var Toolbar = require('@mui/material/Toolbar');
|
|
58
77
|
var Menu = require('@mui/material/Menu');
|
|
@@ -128,10 +147,24 @@ var PauseIcon__default = /*#__PURE__*/_interopDefaultLegacy(PauseIcon);
|
|
|
128
147
|
var StopIcon__default = /*#__PURE__*/_interopDefaultLegacy(StopIcon);
|
|
129
148
|
var FastForwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastForwardIcon);
|
|
130
149
|
var FastRewindIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastRewindIcon);
|
|
131
|
-
var
|
|
150
|
+
var PentagonIcon__default = /*#__PURE__*/_interopDefaultLegacy(PentagonIcon);
|
|
151
|
+
var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
|
|
152
|
+
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
|
|
132
153
|
var TuneIcon__default = /*#__PURE__*/_interopDefaultLegacy(TuneIcon);
|
|
154
|
+
var ScatterPlotIcon__default = /*#__PURE__*/_interopDefaultLegacy(ScatterPlotIcon);
|
|
155
|
+
var PolylineIcon__default = /*#__PURE__*/_interopDefaultLegacy(PolylineIcon);
|
|
156
|
+
var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
|
|
133
157
|
var PlaylistAddIcon__default = /*#__PURE__*/_interopDefaultLegacy(PlaylistAddIcon);
|
|
134
158
|
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
|
|
159
|
+
var AddBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(AddBoxIcon);
|
|
160
|
+
var IndeterminateCheckBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(IndeterminateCheckBoxIcon);
|
|
161
|
+
var csv2geojson__namespace = /*#__PURE__*/_interopNamespace(csv2geojson);
|
|
162
|
+
var osm2geojson__default = /*#__PURE__*/_interopDefaultLegacy(osm2geojson);
|
|
163
|
+
var externParser__namespace = /*#__PURE__*/_interopNamespace(externParser);
|
|
164
|
+
var initSqlJs__default = /*#__PURE__*/_interopDefaultLegacy(initSqlJs);
|
|
165
|
+
var pako__namespace = /*#__PURE__*/_interopNamespace(pako);
|
|
166
|
+
var KeyboardArrowDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardArrowDownIcon);
|
|
167
|
+
var KeyboardArrowUpIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardArrowUpIcon);
|
|
135
168
|
var AppBar__default = /*#__PURE__*/_interopDefaultLegacy(AppBar);
|
|
136
169
|
var Toolbar__default = /*#__PURE__*/_interopDefaultLegacy(Toolbar);
|
|
137
170
|
var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
|
|
@@ -933,7 +966,6 @@ function LayerContextProvider(props) {
|
|
|
933
966
|
setSymbolLayers(symbolLayers);
|
|
934
967
|
};
|
|
935
968
|
React.useEffect(function () {
|
|
936
|
-
console.log('layers', layers);
|
|
937
969
|
if (layers.filter(function (el) { return !(el === null || el === void 0 ? void 0 : el.id); }).length) {
|
|
938
970
|
var _layers = __spreadArray([], layers, true);
|
|
939
971
|
_layers.forEach(function (el) {
|
|
@@ -978,6 +1010,7 @@ function LayerContextProvider(props) {
|
|
|
978
1010
|
setTileUrl: setTileUrl,
|
|
979
1011
|
moveUp: moveUp,
|
|
980
1012
|
moveDown: moveDown,
|
|
1013
|
+
moveLayer: moveLayer,
|
|
981
1014
|
};
|
|
982
1015
|
return React__default["default"].createElement(LayerContext.Provider, { value: value }, props.children);
|
|
983
1016
|
}
|
|
@@ -2569,7 +2602,7 @@ var MlFillExtrusionLayer = function (props) {
|
|
|
2569
2602
|
type: "fill-extrusion",
|
|
2570
2603
|
source: props.sourceId || "openmaptiles",
|
|
2571
2604
|
"source-layer": props.sourceLayer || "building",
|
|
2572
|
-
minzoom: props.minZoom ||
|
|
2605
|
+
minzoom: props.minZoom || 6,
|
|
2573
2606
|
paint: __assign({}, props.paint),
|
|
2574
2607
|
},
|
|
2575
2608
|
insertBeforeFirstSymbolLayer: true,
|
|
@@ -2658,8 +2691,10 @@ var getDefaulLayerTypeByGeometry = function (geojson) {
|
|
|
2658
2691
|
* @component
|
|
2659
2692
|
*/
|
|
2660
2693
|
var MlGeoJsonLayer = function (props) {
|
|
2661
|
-
var _a, _b;
|
|
2694
|
+
var _a, _b, _c;
|
|
2662
2695
|
var layerType = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
2696
|
+
var layerId = props.layerId || 'MlGeoJsonLayer-' + uuid.v4();
|
|
2697
|
+
var labelLayerId = "label-".concat(layerId);
|
|
2663
2698
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
2664
2699
|
useLayer({
|
|
2665
2700
|
mapId: props.mapId,
|
|
@@ -2671,6 +2706,14 @@ var MlGeoJsonLayer = function (props) {
|
|
|
2671
2706
|
onClick: props.onClick,
|
|
2672
2707
|
onLeave: props.onLeave,
|
|
2673
2708
|
});
|
|
2709
|
+
if (props.labelProp) {
|
|
2710
|
+
useLayer({
|
|
2711
|
+
mapId: props.mapId,
|
|
2712
|
+
layerId: labelLayerId,
|
|
2713
|
+
geojson: props.geojson,
|
|
2714
|
+
options: __assign(__assign({ type: 'symbol' }, ((props === null || props === void 0 ? void 0 : props.labelOptions) ? props.labelOptions : {})), { layout: __assign({ 'text-field': "{".concat(props.labelProp, "}") }, (((_c = props === null || props === void 0 ? void 0 : props.labelOptions) === null || _c === void 0 ? void 0 : _c.layout) ? props.labelOptions.layout : {})), paint: {} }),
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2674
2717
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
2675
2718
|
};
|
|
2676
2719
|
|
|
@@ -2854,52 +2897,77 @@ var MlImageMarkerLayer = function (props) {
|
|
|
2854
2897
|
// miles: 1 / 2.58998811,
|
|
2855
2898
|
//};
|
|
2856
2899
|
function getUnitSquareMultiplier(measureType) {
|
|
2857
|
-
return measureType ===
|
|
2900
|
+
return measureType === 'miles' ? 1 / 2.58998811 : 1;
|
|
2858
2901
|
}
|
|
2859
2902
|
function getUnitLabel(measureType) {
|
|
2860
|
-
return measureType ===
|
|
2903
|
+
return measureType === 'miles' ? 'mi' : 'km';
|
|
2861
2904
|
}
|
|
2862
2905
|
var MlMeasureTool = function (props) {
|
|
2863
|
-
var _a = React.useState(0),
|
|
2906
|
+
var _a = React.useState({ value: 0, label: 'km' }), displayValue = _a[0], setDisplayValue = _a[1];
|
|
2864
2907
|
var _b = React.useState([]), currentFeatures = _b[0], setCurrentFeatures = _b[1];
|
|
2865
2908
|
React.useEffect(function () {
|
|
2866
2909
|
if (currentFeatures[0]) {
|
|
2867
|
-
|
|
2910
|
+
var result = props.measureType === 'polygon'
|
|
2911
|
+
// for "polyong" mode calculate km²
|
|
2868
2912
|
? (turf__namespace.area(currentFeatures[0]) / 1000000) * getUnitSquareMultiplier(props.unit)
|
|
2869
|
-
: turf__namespace.length(currentFeatures[0], { units: props.unit })
|
|
2913
|
+
: turf__namespace.length(currentFeatures[0], { units: props.unit });
|
|
2914
|
+
if (typeof props.onChange === 'function') {
|
|
2915
|
+
props.onChange({ value: result, unit: props.unit, geojson: currentFeatures[0] });
|
|
2916
|
+
}
|
|
2917
|
+
if (result >= 0.1) {
|
|
2918
|
+
setDisplayValue({ value: result, label: getUnitLabel(props.unit) });
|
|
2919
|
+
}
|
|
2920
|
+
else {
|
|
2921
|
+
var label = 'm';
|
|
2922
|
+
var value = result * 1000;
|
|
2923
|
+
if (props.measureType === 'polygon') {
|
|
2924
|
+
value = result * 1000000;
|
|
2925
|
+
}
|
|
2926
|
+
if (getUnitLabel(props.unit) === 'mi') {
|
|
2927
|
+
label = 'in';
|
|
2928
|
+
value = result * 63360;
|
|
2929
|
+
if (props.measureType === 'polygon') {
|
|
2930
|
+
value = result * 4014489599.4792;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
setDisplayValue({ value: value, label: label });
|
|
2934
|
+
}
|
|
2870
2935
|
}
|
|
2871
2936
|
}, [props.unit, currentFeatures]);
|
|
2872
2937
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2873
2938
|
React__default["default"].createElement(MlFeatureEditor, { onChange: function (features) {
|
|
2874
2939
|
setCurrentFeatures(features);
|
|
2875
|
-
}, mode: props.measureType ===
|
|
2876
|
-
|
|
2940
|
+
}, mode: props.measureType === 'polygon' ? 'draw_polygon' : 'draw_line_string' }),
|
|
2941
|
+
displayValue.value.toFixed(2),
|
|
2877
2942
|
" ",
|
|
2878
|
-
|
|
2879
|
-
props.measureType ===
|
|
2943
|
+
displayValue.label,
|
|
2944
|
+
props.measureType === 'polygon' ? '²' : ''));
|
|
2880
2945
|
};
|
|
2881
2946
|
MlMeasureTool.defaultProps = {
|
|
2882
2947
|
mapId: undefined,
|
|
2883
|
-
measureType:
|
|
2884
|
-
unit:
|
|
2948
|
+
measureType: 'line',
|
|
2949
|
+
unit: 'kilometers',
|
|
2885
2950
|
};
|
|
2886
2951
|
|
|
2887
|
-
var
|
|
2952
|
+
var _g;
|
|
2888
2953
|
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
2889
2954
|
var SvgCompassNeedle = function SvgCompassNeedle(props) {
|
|
2890
2955
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
2891
|
-
width:
|
|
2956
|
+
width: 10,
|
|
2892
2957
|
height: 40,
|
|
2893
|
-
viewBox: "0 0
|
|
2958
|
+
viewBox: "0 0 10 40",
|
|
2894
2959
|
fill: "none",
|
|
2895
|
-
|
|
2896
|
-
}, props),
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
}
|
|
2900
|
-
d: "
|
|
2901
|
-
fill: "#
|
|
2902
|
-
})
|
|
2960
|
+
id: "svg6"
|
|
2961
|
+
}, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
|
|
2962
|
+
id: "g14",
|
|
2963
|
+
transform: "translate(0.67544,-1.25e-5)"
|
|
2964
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
2965
|
+
d: "m 3.34715,4.52028 c 0.22737,-1.05154 1.72745,-1.05154 1.95482,0 L 8.64912,20 H 0 Z",
|
|
2966
|
+
fill: "#cf003d"
|
|
2967
|
+
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
2968
|
+
d: "m 3.34715,35.4797 c 0.22737,1.0516 1.72745,1.0516 1.95482,0 L 8.64912,20 H 0 Z",
|
|
2969
|
+
fill: "#d3dcf0"
|
|
2970
|
+
}))));
|
|
2903
2971
|
};
|
|
2904
2972
|
|
|
2905
2973
|
var _circle, _path, _path2, _path3, _path4;
|
|
@@ -2952,7 +3020,13 @@ var CompassBox = material.styled(material.Box)(function (_a) {
|
|
|
2952
3020
|
return (_b = {
|
|
2953
3021
|
position: 'absolute',
|
|
2954
3022
|
right: '-10px',
|
|
2955
|
-
top: '-52px'
|
|
3023
|
+
top: '-52px',
|
|
3024
|
+
width: '52px',
|
|
3025
|
+
height: '52px',
|
|
3026
|
+
display: 'flex',
|
|
3027
|
+
flexDirection: 'row',
|
|
3028
|
+
justifyContent: 'center',
|
|
3029
|
+
alignItems: 'center'
|
|
2956
3030
|
},
|
|
2957
3031
|
_b[theme.breakpoints.down('md')] = {
|
|
2958
3032
|
right: '0px',
|
|
@@ -2973,9 +3047,8 @@ var CompassBox = material.styled(material.Box)(function (_a) {
|
|
|
2973
3047
|
var NeedleBox = material.styled(material.Box)(function (_a) {
|
|
2974
3048
|
var theme = _a.theme;
|
|
2975
3049
|
return ({
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
top: '6px',
|
|
3050
|
+
display: 'flex',
|
|
3051
|
+
flexDirection: 'row',
|
|
2979
3052
|
'path:nth-of-type(2)': {
|
|
2980
3053
|
fill: theme.palette.compass.compSouth,
|
|
2981
3054
|
},
|
|
@@ -3031,7 +3104,7 @@ var MlNavigationCompass = function (props) {
|
|
|
3031
3104
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
3032
3105
|
React__default["default"].createElement(BoxStyled$2, { sx: __assign({}, props.style) },
|
|
3033
3106
|
React__default["default"].createElement(CompassBox, { onClick: rotate, sx: __assign({}, props.backgroundStyle) },
|
|
3034
|
-
React__default["default"].createElement(SvgCompassBackground,
|
|
3107
|
+
React__default["default"].createElement(SvgCompassBackground, { style: { position: 'absolute', top: 0, left: 0 } }),
|
|
3035
3108
|
React__default["default"].createElement(NeedleBox, { onClick: rotate, sx: __assign({}, props.needleStyle) },
|
|
3036
3109
|
React__default["default"].createElement(SvgCompassNeedle, { style: {
|
|
3037
3110
|
transform: 'rotate(' + (bearing > 0 ? '-' + bearing : -1 * bearing) + 'deg)',
|
|
@@ -3081,7 +3154,7 @@ var MlNavigationTools = function (props) {
|
|
|
3081
3154
|
}, [mapHook.map]);
|
|
3082
3155
|
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) },
|
|
3083
3156
|
React__default["default"].createElement(MlNavigationCompass, null),
|
|
3084
|
-
props.show3DButton && (React__default["default"].createElement(Button__default["default"], { variant: "navtools", onClick: adjustPitch }, pitch <
|
|
3157
|
+
props.show3DButton && (React__default["default"].createElement(Button__default["default"], { variant: "navtools", onClick: adjustPitch }, pitch < 29 ? '3D' : '2D')),
|
|
3085
3158
|
props.showFollowGpsButton && React__default["default"].createElement(MlFollowGps, null),
|
|
3086
3159
|
props.showCenterLocationButton && React__default["default"].createElement(MlCenterPosition, null),
|
|
3087
3160
|
React__default["default"].createElement(ButtonGroup__default["default"], { orientation: "vertical", sx: {
|
|
@@ -3114,9 +3187,9 @@ var MlLayer = function (props) {
|
|
|
3114
3187
|
idPrefix: 'MlLayer-',
|
|
3115
3188
|
layerId: props.layerId,
|
|
3116
3189
|
mapId: props.mapId,
|
|
3117
|
-
geojson: props.geojson,
|
|
3118
|
-
options: __assign({ type:
|
|
3119
|
-
|
|
3190
|
+
geojson: props.geojson || undefined,
|
|
3191
|
+
options: __assign({ type: 'background', paint: {
|
|
3192
|
+
'background-color': 'rgba(0,0,0,0)',
|
|
3120
3193
|
} }, props.options),
|
|
3121
3194
|
insertBeforeLayer: props.insertBeforeLayer,
|
|
3122
3195
|
});
|
|
@@ -3401,7 +3474,7 @@ var MlLayerSwipe = function (props) {
|
|
|
3401
3474
|
});
|
|
3402
3475
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
3403
3476
|
var onDown = function (e) {
|
|
3404
|
-
if (e.nativeEvent instanceof TouchEvent) {
|
|
3477
|
+
if ((window === null || window === void 0 ? void 0 : window.TouchEvent) && e.nativeEvent instanceof window.TouchEvent) {
|
|
3405
3478
|
document.addEventListener('touchmove', onMove);
|
|
3406
3479
|
document.addEventListener('touchend', onTouchEnd);
|
|
3407
3480
|
}
|
|
@@ -5347,6 +5420,17 @@ ConfirmDialog.defaultProps = {
|
|
|
5347
5420
|
text: 'Are you sure?',
|
|
5348
5421
|
};
|
|
5349
5422
|
|
|
5423
|
+
function SortableContainer(_a) {
|
|
5424
|
+
var children = _a.children, layerId = _a.layerId;
|
|
5425
|
+
var _b = sortable.useSortable({
|
|
5426
|
+
id: layerId,
|
|
5427
|
+
}), attributes = _b.attributes, listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform;
|
|
5428
|
+
var style = {
|
|
5429
|
+
transform: utilities.CSS.Transform.toString(transform),
|
|
5430
|
+
};
|
|
5431
|
+
return (React__default["default"].createElement("li", __assign({ ref: setNodeRef, style: style }, attributes, listeners), children));
|
|
5432
|
+
}
|
|
5433
|
+
|
|
5350
5434
|
var originShift = (2 * Math.PI * 6378137) / 2.0;
|
|
5351
5435
|
var lngLatToMeters = function (lnglat, accuracy) {
|
|
5352
5436
|
if (accuracy === void 0) { accuracy = { enable: true, decimal: 1 }; }
|
|
@@ -5561,57 +5645,59 @@ var MlWmsLoader = function (props) {
|
|
|
5561
5645
|
}
|
|
5562
5646
|
}
|
|
5563
5647
|
}, [capabilities, mapHook.map]);
|
|
5648
|
+
var listContent = (React__default["default"].createElement(ListItem__default["default"], { secondaryAction: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5649
|
+
props.buttons,
|
|
5650
|
+
props.featureInfoEnabled && (React__default["default"].createElement(IconButton__default["default"], { sx: {
|
|
5651
|
+
padding: '4px',
|
|
5652
|
+
marginTop: '-3px',
|
|
5653
|
+
marginRight: '4px',
|
|
5654
|
+
background: function (theme) {
|
|
5655
|
+
if (!(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })))
|
|
5656
|
+
return 'initial';
|
|
5657
|
+
if (_featureInfoEventsEnabled)
|
|
5658
|
+
return theme.palette.info.light;
|
|
5659
|
+
return theme.palette.grey[300];
|
|
5660
|
+
},
|
|
5661
|
+
}, "aria-label": "featureinfo", onClick: function () {
|
|
5662
|
+
if (typeof (props === null || props === void 0 ? void 0 : props.setFeatureInfoActive) === 'function') {
|
|
5663
|
+
props.setFeatureInfoActive(function (current) { return !current; });
|
|
5664
|
+
}
|
|
5665
|
+
else {
|
|
5666
|
+
setFeatureInfoEventsEnabled(function (current) { return !current; });
|
|
5667
|
+
}
|
|
5668
|
+
}, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
|
|
5669
|
+
React__default["default"].createElement(InfoIcon__default["default"], null))),
|
|
5670
|
+
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)),
|
|
5671
|
+
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5672
|
+
React__default["default"].createElement(IconButton__default["default"], { "aria-label": "delete", edge: "end", onClick: function () {
|
|
5673
|
+
if (typeof props.onConfigChange === 'function') {
|
|
5674
|
+
setShowDeletionConfirmationDialog(true);
|
|
5675
|
+
}
|
|
5676
|
+
}, sx: { padding: '4px', marginTop: '-3px' } },
|
|
5677
|
+
React__default["default"].createElement(DeleteIcon__default["default"], null)),
|
|
5678
|
+
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
5679
|
+
if (typeof props.onConfigChange === 'function') {
|
|
5680
|
+
props.onConfigChange(false);
|
|
5681
|
+
}
|
|
5682
|
+
}, onCancel: function () {
|
|
5683
|
+
setShowDeletionConfirmationDialog(false);
|
|
5684
|
+
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" }))))), sx: {
|
|
5685
|
+
paddingRight: 0,
|
|
5686
|
+
paddingLeft: 0,
|
|
5687
|
+
paddingTop: 0,
|
|
5688
|
+
paddingBottom: '4px',
|
|
5689
|
+
} },
|
|
5690
|
+
React__default["default"].createElement(material.ListItemIcon, { sx: { minWidth: '30px' } },
|
|
5691
|
+
React__default["default"].createElement(material.Checkbox, { sx: { padding: 0 }, checked: visible, onClick: function () {
|
|
5692
|
+
setVisible(function (val) { return !val; });
|
|
5693
|
+
} })),
|
|
5694
|
+
React__default["default"].createElement(ListItemText__default["default"], { primary: name, variant: "layerlist" })));
|
|
5564
5695
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5565
5696
|
error && (React__default["default"].createElement(material.Snackbar, null,
|
|
5566
5697
|
React__default["default"].createElement(material.Box, null, error))),
|
|
5567
5698
|
wmsUrl && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5568
|
-
React__default["default"].createElement(
|
|
5569
|
-
|
|
5570
|
-
props.featureInfoEnabled && (React__default["default"].createElement(IconButton__default["default"], { sx: {
|
|
5571
|
-
padding: '4px',
|
|
5572
|
-
marginTop: '-3px',
|
|
5573
|
-
marginRight: '4px',
|
|
5574
|
-
background: function (theme) {
|
|
5575
|
-
if (!(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })))
|
|
5576
|
-
return 'initial';
|
|
5577
|
-
if (_featureInfoEventsEnabled)
|
|
5578
|
-
return theme.palette.info.light;
|
|
5579
|
-
return theme.palette.grey[300];
|
|
5580
|
-
},
|
|
5581
|
-
}, "aria-label": "featureinfo", onClick: function () {
|
|
5582
|
-
if (typeof (props === null || props === void 0 ? void 0 : props.setFeatureInfoActive) === 'function') {
|
|
5583
|
-
props.setFeatureInfoActive(function (current) { return !current; });
|
|
5584
|
-
}
|
|
5585
|
-
else {
|
|
5586
|
-
setFeatureInfoEventsEnabled(function (current) { return !current; });
|
|
5587
|
-
}
|
|
5588
|
-
}, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
|
|
5589
|
-
React__default["default"].createElement(InfoIcon__default["default"], null))),
|
|
5590
|
-
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)),
|
|
5591
|
-
props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5592
|
-
React__default["default"].createElement(IconButton__default["default"], { "aria-label": "delete", edge: "end", onClick: function () {
|
|
5593
|
-
if (typeof props.onConfigChange === 'function') {
|
|
5594
|
-
setShowDeletionConfirmationDialog(true);
|
|
5595
|
-
}
|
|
5596
|
-
}, sx: { padding: '4px', marginTop: '-3px' } },
|
|
5597
|
-
React__default["default"].createElement(DeleteIcon__default["default"], null)),
|
|
5598
|
-
showDeletionConfirmationDialog && (React__default["default"].createElement(ConfirmDialog, { open: showDeletionConfirmationDialog, onConfirm: function () {
|
|
5599
|
-
if (typeof props.onConfigChange === 'function') {
|
|
5600
|
-
props.onConfigChange(false);
|
|
5601
|
-
}
|
|
5602
|
-
}, onCancel: function () {
|
|
5603
|
-
setShowDeletionConfirmationDialog(false);
|
|
5604
|
-
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" }))))), sx: {
|
|
5605
|
-
paddingRight: 0,
|
|
5606
|
-
paddingLeft: 0,
|
|
5607
|
-
paddingTop: 0,
|
|
5608
|
-
paddingBottom: '4px',
|
|
5609
|
-
} },
|
|
5610
|
-
React__default["default"].createElement(material.ListItemIcon, { sx: { minWidth: '30px' } },
|
|
5611
|
-
React__default["default"].createElement(material.Checkbox, { sx: { padding: 0 }, checked: visible, onClick: function () {
|
|
5612
|
-
setVisible(function (val) { return !val; });
|
|
5613
|
-
} })),
|
|
5614
|
-
React__default["default"].createElement(ListItemText__default["default"], { primary: name, variant: "layerlist" })),
|
|
5699
|
+
props.layerId && props.sortable && (React__default["default"].createElement(SortableContainer, { layerId: props.layerId }, listContent)),
|
|
5700
|
+
props.layerId && !props.sortable && (listContent),
|
|
5615
5701
|
React__default["default"].createElement(material.Box, { sx: { display: open ? 'block' : 'none' } },
|
|
5616
5702
|
React__default["default"].createElement(List__default["default"], { dense: true, component: "div", disablePadding: true, sx: { paddingLeft: '18px' } }, wmsUrl &&
|
|
5617
5703
|
((_j = layers === null || layers === void 0 ? void 0 : layers.map) === null || _j === void 0 ? void 0 : _j.call(layers, function (layer, idx) {
|
|
@@ -6220,385 +6306,80 @@ MlTerrainLayer.defaultProps = {
|
|
|
6220
6306
|
mapId: undefined,
|
|
6221
6307
|
};
|
|
6222
6308
|
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6309
|
+
var ListItemStyled$1 = system.styled(material.ListItem)({
|
|
6310
|
+
paddingRight: 0,
|
|
6311
|
+
paddingLeft: 0,
|
|
6312
|
+
paddingTop: 0,
|
|
6313
|
+
paddingBottom: '4px',
|
|
6314
|
+
});
|
|
6315
|
+
var ListItemIconStyled = system.styled(material.ListItemIcon)({
|
|
6316
|
+
minWidth: '30px',
|
|
6317
|
+
});
|
|
6318
|
+
var IconButtonStyled$1 = system.styled(material.IconButton)({
|
|
6319
|
+
marginRight: '0px',
|
|
6320
|
+
padding: '0px',
|
|
6321
|
+
});
|
|
6322
|
+
var CheckboxStyled$1 = system.styled(material.Checkbox)({
|
|
6323
|
+
padding: 0,
|
|
6324
|
+
marginRight: '5px',
|
|
6325
|
+
});
|
|
6326
|
+
var BoxStyled$1 = system.styled(system.Box)(function (_a) {
|
|
6327
|
+
var open = _a.open;
|
|
6328
|
+
return ({
|
|
6329
|
+
display: open ? 'block' : 'none',
|
|
6243
6330
|
});
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
React.
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
mapHook.map.map.setZoom(zoom.current);
|
|
6256
|
-
}
|
|
6257
|
-
}, [mapHook.map, props.zoom]);
|
|
6258
|
-
React.useEffect(function () {
|
|
6259
|
-
if (!mapHook.map)
|
|
6260
|
-
return;
|
|
6261
|
-
pitch.current = props.pitch;
|
|
6262
|
-
if (typeof pitch.current !== 'undefined' && pitch.current !== mapHook.map.map.getPitch()) {
|
|
6263
|
-
mapHook.map.map.setPitch(pitch.current);
|
|
6264
|
-
}
|
|
6265
|
-
}, [mapHook.map, props.pitch]);
|
|
6266
|
-
React.useEffect(function () {
|
|
6267
|
-
speed.current = props.speed;
|
|
6268
|
-
}, [props.speed]);
|
|
6269
|
-
var disableInteractivity = React.useCallback(function () {
|
|
6270
|
-
if (!mapHook.map)
|
|
6271
|
-
return;
|
|
6272
|
-
mapHook.map.map['scrollZoom'].disable();
|
|
6273
|
-
mapHook.map.map['boxZoom'].disable();
|
|
6274
|
-
mapHook.map.map['dragRotate'].disable();
|
|
6275
|
-
mapHook.map.map['dragPan'].disable();
|
|
6276
|
-
mapHook.map.map['keyboard'].disable();
|
|
6277
|
-
mapHook.map.map['doubleClickZoom'].disable();
|
|
6278
|
-
mapHook.map.map['touchZoomRotate'].disable();
|
|
6279
|
-
}, [mapHook.map]);
|
|
6280
|
-
var enableInteractivity = React.useCallback(function () {
|
|
6281
|
-
if (!mapHook.map)
|
|
6282
|
-
return;
|
|
6283
|
-
mapHook.map.map['scrollZoom'].enable();
|
|
6284
|
-
mapHook.map.map['boxZoom'].enable();
|
|
6285
|
-
mapHook.map.map['dragRotate'].enable();
|
|
6286
|
-
mapHook.map.map['dragPan'].enable();
|
|
6287
|
-
mapHook.map.map['keyboard'].enable();
|
|
6288
|
-
mapHook.map.map['doubleClickZoom'].enable();
|
|
6289
|
-
mapHook.map.map['touchZoomRotate'].enable();
|
|
6290
|
-
}, [mapHook.map]);
|
|
6291
|
-
function centerRoute() {
|
|
6292
|
-
if (!mapHook.map || !props.route)
|
|
6293
|
-
return;
|
|
6294
|
-
var bbox = turf__namespace.bbox(props.route);
|
|
6295
|
-
var bounds;
|
|
6296
|
-
if (bbox && bbox.length > 3) {
|
|
6297
|
-
bounds = [
|
|
6298
|
-
[bbox[0], bbox[1]],
|
|
6299
|
-
[bbox[2], bbox[3]],
|
|
6300
|
-
];
|
|
6301
|
-
mapHook.map.map.fitBounds(bounds, { padding: 100 });
|
|
6331
|
+
});
|
|
6332
|
+
var ListStyled$1 = system.styled(material.List)({
|
|
6333
|
+
marginLeft: '50px',
|
|
6334
|
+
});
|
|
6335
|
+
function LayerListFolder(_a) {
|
|
6336
|
+
var _b = _a.visible, visible = _b === void 0 ? true : _b, name = _a.name, children = _a.children, setVisible = _a.setVisible;
|
|
6337
|
+
var _c = React.useState(false), open = _c[0], setOpen = _c[1];
|
|
6338
|
+
var _d = React.useState(true), localVisible = _d[0], setLocalVisible = _d[1];
|
|
6339
|
+
var _visible = React.useMemo(function () {
|
|
6340
|
+
if (!visible) {
|
|
6341
|
+
return false;
|
|
6302
6342
|
}
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
var alongRoutelati = turf__namespace.along(props.route, step.current * kmPerStep).geometry
|
|
6313
|
-
.coordinates;
|
|
6314
|
-
if (step.current * kmPerStep < routeDistance) {
|
|
6315
|
-
mapHook.map.map.easeTo({
|
|
6316
|
-
center: alongRoutelati,
|
|
6317
|
-
bearing: turf__namespace.bearing(turf__namespace.point([mapHook.map.map.getCenter().lng, mapHook.map.map.getCenter().lat]), turf__namespace.point(alongRoutelati)),
|
|
6318
|
-
duration: stepDuration,
|
|
6319
|
-
essential: true,
|
|
6343
|
+
return localVisible;
|
|
6344
|
+
}, [visible, localVisible]);
|
|
6345
|
+
var _children = React.useMemo(function () {
|
|
6346
|
+
if (children) {
|
|
6347
|
+
if (Array.isArray(children)) {
|
|
6348
|
+
return children.map(function (element) {
|
|
6349
|
+
return React__default["default"].cloneElement(element, {
|
|
6350
|
+
visible: _visible,
|
|
6351
|
+
});
|
|
6320
6352
|
});
|
|
6321
|
-
if (typeof speed.current !== 'undefined') {
|
|
6322
|
-
step.current = step.current + speed.current;
|
|
6323
|
-
}
|
|
6324
|
-
else {
|
|
6325
|
-
step.current++;
|
|
6326
|
-
}
|
|
6327
|
-
console.log('PAN MOVE');
|
|
6328
|
-
setTimeout(function () {
|
|
6329
|
-
play();
|
|
6330
|
-
}, 100);
|
|
6331
|
-
}
|
|
6332
|
-
else {
|
|
6333
|
-
mapHook.map.map.setPitch(0);
|
|
6334
|
-
centerRoute();
|
|
6335
|
-
enableInteractivity();
|
|
6336
|
-
console.log('ENABLE CONTROLS');
|
|
6337
|
-
step.current = 1;
|
|
6338
6353
|
}
|
|
6354
|
+
return React__default["default"].cloneElement(children, {
|
|
6355
|
+
visible: _visible,
|
|
6356
|
+
});
|
|
6339
6357
|
}
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
return
|
|
6365
|
-
play: play,
|
|
6366
|
-
reset: reset,
|
|
6367
|
-
};
|
|
6368
|
-
};
|
|
6369
|
-
useCameraFollowPath.defaultProps = {
|
|
6370
|
-
mapId: undefined,
|
|
6371
|
-
zoom: 18,
|
|
6372
|
-
};
|
|
6373
|
-
|
|
6374
|
-
function useLayerFilter(props) {
|
|
6375
|
-
var mapHook = useMap({ mapId: props.mapId });
|
|
6376
|
-
React.useEffect(function () {
|
|
6377
|
-
if (!mapHook.map || !props.layerId || !props.filter)
|
|
6378
|
-
return;
|
|
6379
|
-
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
6380
|
-
var _layerId_1 = props.layerId;
|
|
6381
|
-
mapHook.map.map.setFilter(_layerId_1, props.filter);
|
|
6382
|
-
return function () {
|
|
6383
|
-
if (mapHook.map) {
|
|
6384
|
-
mapHook.map.map.setFilter(_layerId_1, null);
|
|
6385
|
-
}
|
|
6386
|
-
};
|
|
6387
|
-
}
|
|
6388
|
-
return;
|
|
6389
|
-
}, [props, mapHook.map]);
|
|
6390
|
-
return {};
|
|
6391
|
-
}
|
|
6392
|
-
|
|
6393
|
-
var touchEquivalents = {
|
|
6394
|
-
mousedown: 'touchstart',
|
|
6395
|
-
mouseup: 'touchend',
|
|
6396
|
-
mousemove: 'touchmove'
|
|
6397
|
-
};
|
|
6398
|
-
var touchEquivalentsKeys = Object.keys(touchEquivalents);
|
|
6399
|
-
function useLayerEvent(props) {
|
|
6400
|
-
var mapState = useMapState({
|
|
6401
|
-
mapId: props.mapId,
|
|
6402
|
-
watch: {
|
|
6403
|
-
layers: true
|
|
6404
|
-
}
|
|
6405
|
-
});
|
|
6406
|
-
var mapHook = useMap({
|
|
6407
|
-
mapId: props.mapId
|
|
6408
|
-
});
|
|
6409
|
-
React.useEffect(function () {
|
|
6410
|
-
if (!mapHook.map) return true;
|
|
6411
|
-
if (typeof props.condition !== 'undefined' && props.condition === false) return;
|
|
6412
|
-
//console.log('useLayerEvent');
|
|
6413
|
-
//console.log(mapState);
|
|
6414
|
-
|
|
6415
|
-
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
6416
|
-
//console.log("layer avail");
|
|
6417
|
-
var _event = props.event;
|
|
6418
|
-
var _layerId = props.layerId;
|
|
6419
|
-
var _eventHandler = props.eventHandler;
|
|
6420
|
-
|
|
6421
|
-
//console.log(_event);
|
|
6422
|
-
mapHook.map.on(_event, _layerId, _eventHandler, mapHook.componentId);
|
|
6423
|
-
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
6424
|
-
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
6425
|
-
mapHook.map.on(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
6426
|
-
}
|
|
6427
|
-
}
|
|
6428
|
-
return function () {
|
|
6429
|
-
mapHook.map.off(_event, _layerId, _eventHandler);
|
|
6430
|
-
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
6431
|
-
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
6432
|
-
mapHook.map.off(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
6433
|
-
}
|
|
6434
|
-
}
|
|
6435
|
-
};
|
|
6436
|
-
}
|
|
6437
|
-
}, [props, mapState, mapHook.map]);
|
|
6438
|
-
return {};
|
|
6439
|
-
}
|
|
6440
|
-
|
|
6441
|
-
var useLayerContext = function () {
|
|
6442
|
-
var layerContext = React.useContext(LayerContext);
|
|
6443
|
-
return layerContext;
|
|
6444
|
-
};
|
|
6445
|
-
|
|
6446
|
-
/**
|
|
6447
|
-
* Enables the use of custom protocols (basically custom tile load functions) in the maplibre-gl-js library.
|
|
6448
|
-
*
|
|
6449
|
-
*/
|
|
6450
|
-
var useAddProtocol = function (props) {
|
|
6451
|
-
React.useEffect(function () {
|
|
6452
|
-
if (!props.protocol || typeof props.handler !== 'function')
|
|
6453
|
-
return;
|
|
6454
|
-
maplibregl__default["default"].addProtocol(props.protocol, props.handler);
|
|
6455
|
-
return function () {
|
|
6456
|
-
maplibregl__default["default"].removeProtocol(props.protocol);
|
|
6457
|
-
};
|
|
6458
|
-
}, []);
|
|
6459
|
-
return {};
|
|
6460
|
-
};
|
|
6461
|
-
useAddProtocol.defaultProps = {
|
|
6462
|
-
mapId: undefined,
|
|
6463
|
-
};
|
|
6464
|
-
|
|
6465
|
-
var SimpleDataContext = /*#__PURE__*/React__default["default"].createContext({});
|
|
6466
|
-
var SimpleDataContextProvider = SimpleDataContext.Provider;
|
|
6467
|
-
|
|
6468
|
-
var SimpleDataProvider = function SimpleDataProvider(props) {
|
|
6469
|
-
var _useState = React.useState(null),
|
|
6470
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
6471
|
-
data = _useState2[0],
|
|
6472
|
-
setData = _useState2[1];
|
|
6473
|
-
React.useEffect(function () {
|
|
6474
|
-
if (!props.url) return;
|
|
6475
|
-
var data_promise = null;
|
|
6476
|
-
if (props.format === "json") {
|
|
6477
|
-
data_promise = d3__namespace.json(props.url);
|
|
6478
|
-
} else if (props.format === "csv") {
|
|
6479
|
-
data_promise = d3__namespace.csv(props.url);
|
|
6480
|
-
} else if (props.format === "xml") {
|
|
6481
|
-
data_promise = d3__namespace.xml(props.url);
|
|
6482
|
-
}
|
|
6483
|
-
if (data_promise) {
|
|
6484
|
-
data_promise.then(function (received_data) {
|
|
6485
|
-
if (props.format === "xml") {
|
|
6486
|
-
if (props.nodeType) {
|
|
6487
|
-
var dataTmp = [];
|
|
6488
|
-
received_data.querySelectorAll(props.nodeType).forEach(function (el) {
|
|
6489
|
-
dataTmp.push(props.formatData(el));
|
|
6490
|
-
});
|
|
6491
|
-
setData(dataTmp);
|
|
6492
|
-
}
|
|
6493
|
-
} else {
|
|
6494
|
-
if (props.data_property) {
|
|
6495
|
-
received_data = received_data[props.data_property];
|
|
6496
|
-
}
|
|
6497
|
-
if (typeof props.formatData === "function") {
|
|
6498
|
-
setData(received_data.map(props.formatData));
|
|
6499
|
-
} else {
|
|
6500
|
-
setData(received_data);
|
|
6501
|
-
}
|
|
6502
|
-
}
|
|
6503
|
-
if (typeof props.onData === "function") {
|
|
6504
|
-
props.onData();
|
|
6505
|
-
}
|
|
6506
|
-
});
|
|
6507
|
-
}
|
|
6508
|
-
}, [props.url, props]);
|
|
6509
|
-
var value = {
|
|
6510
|
-
data: data,
|
|
6511
|
-
setData: setData
|
|
6512
|
-
};
|
|
6513
|
-
return /*#__PURE__*/React__default["default"].createElement(SimpleDataContextProvider, {
|
|
6514
|
-
value: value
|
|
6515
|
-
}, props.children);
|
|
6516
|
-
};
|
|
6517
|
-
SimpleDataProvider.propTypes = {
|
|
6518
|
-
children: PropTypes__default["default"].node.isRequired
|
|
6519
|
-
};
|
|
6520
|
-
|
|
6521
|
-
var ListStyled$1 = material.styled(material.List)({
|
|
6522
|
-
marginTop: '15px',
|
|
6523
|
-
});
|
|
6524
|
-
function LayerList(props) {
|
|
6525
|
-
return React__default["default"].createElement(ListStyled$1, null, props === null || props === void 0 ? void 0 : props.children);
|
|
6526
|
-
}
|
|
6527
|
-
|
|
6528
|
-
var ListItemStyled$1 = system.styled(material.ListItem)({
|
|
6529
|
-
paddingRight: 0,
|
|
6530
|
-
paddingLeft: 0,
|
|
6531
|
-
paddingTop: 0,
|
|
6532
|
-
paddingBottom: '4px',
|
|
6533
|
-
});
|
|
6534
|
-
var ListItemIconStyled = system.styled(material.ListItemIcon)({
|
|
6535
|
-
minWidth: '30px',
|
|
6536
|
-
});
|
|
6537
|
-
var IconButtonStyled$1 = system.styled(material.IconButton)({
|
|
6538
|
-
marginRight: '0px',
|
|
6539
|
-
padding: '0px',
|
|
6540
|
-
});
|
|
6541
|
-
var CheckboxStyled$1 = system.styled(material.Checkbox)({
|
|
6542
|
-
padding: 0,
|
|
6543
|
-
marginRight: '5px',
|
|
6544
|
-
});
|
|
6545
|
-
var BoxStyled$1 = system.styled(system.Box)(function (_a) {
|
|
6546
|
-
var open = _a.open;
|
|
6547
|
-
return ({
|
|
6548
|
-
display: open ? 'block' : 'none',
|
|
6549
|
-
});
|
|
6550
|
-
});
|
|
6551
|
-
var ListStyled = system.styled(material.List)({
|
|
6552
|
-
marginLeft: '50px',
|
|
6553
|
-
});
|
|
6554
|
-
function LayerListFolder(_a) {
|
|
6555
|
-
var _b = _a.visible, visible = _b === void 0 ? true : _b, name = _a.name, children = _a.children, setVisible = _a.setVisible;
|
|
6556
|
-
var _c = React.useState(false), open = _c[0], setOpen = _c[1];
|
|
6557
|
-
var _d = React.useState(true), localVisible = _d[0], setLocalVisible = _d[1];
|
|
6558
|
-
var _visible = React.useMemo(function () {
|
|
6559
|
-
if (!visible) {
|
|
6560
|
-
return false;
|
|
6561
|
-
}
|
|
6562
|
-
return localVisible;
|
|
6563
|
-
}, [visible, localVisible]);
|
|
6564
|
-
var _children = React.useMemo(function () {
|
|
6565
|
-
if (children) {
|
|
6566
|
-
if (Array.isArray(children)) {
|
|
6567
|
-
return children.map(function (element) {
|
|
6568
|
-
return React__default["default"].cloneElement(element, {
|
|
6569
|
-
visible: _visible,
|
|
6570
|
-
});
|
|
6571
|
-
});
|
|
6572
|
-
}
|
|
6573
|
-
return React__default["default"].cloneElement(children, {
|
|
6574
|
-
visible: _visible,
|
|
6575
|
-
});
|
|
6576
|
-
}
|
|
6577
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
6578
|
-
}, [_visible]);
|
|
6579
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6580
|
-
React__default["default"].createElement(ListItemStyled$1, null,
|
|
6581
|
-
React__default["default"].createElement(ListItemIconStyled, null,
|
|
6582
|
-
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)),
|
|
6583
|
-
React__default["default"].createElement(CheckboxStyled$1, { disabled: setVisible ? false : !visible, checked: setVisible ? visible : localVisible, onClick: function () {
|
|
6584
|
-
if (setVisible) {
|
|
6585
|
-
setVisible(function (val) { return !val; });
|
|
6586
|
-
}
|
|
6587
|
-
else {
|
|
6588
|
-
setLocalVisible(function (val) { return !val; });
|
|
6589
|
-
}
|
|
6590
|
-
} })),
|
|
6591
|
-
React__default["default"].createElement(material.ListItemText, { primary: name, variant: "layerlist" })),
|
|
6592
|
-
React__default["default"].createElement(BoxStyled$1, { open: open },
|
|
6593
|
-
React__default["default"].createElement(ListStyled, { disablePadding: true }, _children))));
|
|
6594
|
-
}
|
|
6595
|
-
|
|
6596
|
-
var converters = {
|
|
6597
|
-
rgba: function (c) { return "rgba(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ", ").concat(c.rgb.a, ")"); },
|
|
6598
|
-
rgb: function (c) { return "rgb(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ")"); },
|
|
6599
|
-
hex: function (c) { return c.hex; },
|
|
6600
|
-
rgba_rgb: function (c) { return c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c); },
|
|
6601
|
-
rgba_hex: function (c) { return c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c); }
|
|
6358
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
6359
|
+
}, [_visible]);
|
|
6360
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6361
|
+
React__default["default"].createElement(ListItemStyled$1, null,
|
|
6362
|
+
React__default["default"].createElement(ListItemIconStyled, null,
|
|
6363
|
+
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)),
|
|
6364
|
+
React__default["default"].createElement(CheckboxStyled$1, { disabled: setVisible ? false : !visible, checked: setVisible ? visible : localVisible, onClick: function () {
|
|
6365
|
+
if (setVisible) {
|
|
6366
|
+
setVisible(function (val) { return !val; });
|
|
6367
|
+
}
|
|
6368
|
+
else {
|
|
6369
|
+
setLocalVisible(function (val) { return !val; });
|
|
6370
|
+
}
|
|
6371
|
+
} })),
|
|
6372
|
+
React__default["default"].createElement(material.ListItemText, { primary: name, variant: "layerlist" })),
|
|
6373
|
+
React__default["default"].createElement(BoxStyled$1, { open: open },
|
|
6374
|
+
React__default["default"].createElement(ListStyled$1, { disablePadding: true }, _children))));
|
|
6375
|
+
}
|
|
6376
|
+
|
|
6377
|
+
var converters = {
|
|
6378
|
+
rgba: function (c) { return "rgba(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ", ").concat(c.rgb.a, ")"); },
|
|
6379
|
+
rgb: function (c) { return "rgb(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ")"); },
|
|
6380
|
+
hex: function (c) { return c.hex; },
|
|
6381
|
+
rgba_rgb: function (c) { return c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c); },
|
|
6382
|
+
rgba_hex: function (c) { return c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c); }
|
|
6602
6383
|
};
|
|
6603
6384
|
|
|
6604
6385
|
var ColorPicker = function (_a) {
|
|
@@ -6817,16 +6598,16 @@ var DeleteIconButton = material.styled(material.IconButton)({
|
|
|
6817
6598
|
marginLeft: '20px',
|
|
6818
6599
|
});
|
|
6819
6600
|
function LayerListItem(_a) {
|
|
6820
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6601
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
6821
6602
|
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"]);
|
|
6822
|
-
var
|
|
6823
|
-
var
|
|
6824
|
-
var
|
|
6603
|
+
var _p = React.useState(true), localVisible = _p[0], setLocalVisible = _p[1];
|
|
6604
|
+
var _q = React.useState(false), paintPropsFormVisible = _q[0], setPaintPropsFormVisible = _q[1];
|
|
6605
|
+
var _r = React.useState(false), showDeletionConfirmationDialog = _r[0], setShowDeletionConfirmationDialog = _r[1];
|
|
6825
6606
|
var deletedRef = React.useRef(false);
|
|
6826
6607
|
var visibleRef = React.useRef(visible);
|
|
6827
6608
|
// this state variable is used for layer components that provide a paint attribute
|
|
6828
|
-
var
|
|
6829
|
-
getDefaultPaintPropsByType(((_c = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _c === void 0 ? void 0 : _c.type) || getDefaulLayerTypeByGeometry(layerComponent.props.geojson))), paintProps =
|
|
6609
|
+
var _s = React.useState(((_b = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _b === void 0 ? void 0 : _b.paint) ||
|
|
6610
|
+
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];
|
|
6830
6611
|
var _visible = React.useMemo(function () {
|
|
6831
6612
|
if (!visible) {
|
|
6832
6613
|
return false;
|
|
@@ -6894,22 +6675,24 @@ function LayerListItem(_a) {
|
|
|
6894
6675
|
}
|
|
6895
6676
|
return undefined;
|
|
6896
6677
|
}, [layerComponent]);
|
|
6678
|
+
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 :
|
|
6679
|
+
props.buttons,
|
|
6680
|
+
React__default["default"].createElement(TuneIconButton, { edge: 'end', "aria-label": "settings", onClick: function () {
|
|
6681
|
+
setPaintPropsFormVisible(function (current) {
|
|
6682
|
+
return !current;
|
|
6683
|
+
});
|
|
6684
|
+
} },
|
|
6685
|
+
React__default["default"].createElement(iconsMaterial.Tune, null)))) : undefined },
|
|
6686
|
+
React__default["default"].createElement(CheckboxListItemIcon, null,
|
|
6687
|
+
React__default["default"].createElement(CheckboxStyled, { disabled: !visible, checked: localVisible, onClick: function () {
|
|
6688
|
+
setLocalVisible(function (val) { return !val; });
|
|
6689
|
+
} })),
|
|
6690
|
+
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description, primaryTypographyProps: { overflow: 'hidden' } })));
|
|
6897
6691
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6898
|
-
!((
|
|
6899
|
-
|
|
6900
|
-
React__default["default"].createElement(TuneIconButton, { edge: 'end', "aria-label": "settings", onClick: function () {
|
|
6901
|
-
setPaintPropsFormVisible(function (current) {
|
|
6902
|
-
return !current;
|
|
6903
|
-
});
|
|
6904
|
-
} },
|
|
6905
|
-
React__default["default"].createElement(iconsMaterial.Tune, null)))) : undefined },
|
|
6906
|
-
React__default["default"].createElement(CheckboxListItemIcon, null,
|
|
6907
|
-
React__default["default"].createElement(CheckboxStyled, { disabled: !visible, checked: localVisible, onClick: function () {
|
|
6908
|
-
setLocalVisible(function (val) { return !val; });
|
|
6909
|
-
} })),
|
|
6910
|
-
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description, primaryTypographyProps: { overflow: 'hidden' } }))),
|
|
6692
|
+
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)),
|
|
6693
|
+
!props.sortable && !((_h = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _h === void 0 ? void 0 : _h.layers) && (listContent),
|
|
6911
6694
|
_layerComponent,
|
|
6912
|
-
!((
|
|
6695
|
+
!((_j = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _j === void 0 ? void 0 : _j.layers) &&
|
|
6913
6696
|
Object.keys(paintProps).length > 0 &&
|
|
6914
6697
|
configurable &&
|
|
6915
6698
|
paintPropsFormVisible && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
@@ -6930,7 +6713,7 @@ function LayerListItem(_a) {
|
|
|
6930
6713
|
setShowDeletionConfirmationDialog(false);
|
|
6931
6714
|
}, title: "Delete layer", text: "Are you sure you want to delete this layer?" })))),
|
|
6932
6715
|
React__default["default"].createElement(LayerPropertyForm, { paintProps: paintProps, setPaintProps: setPaintProps, layerType: layerType }))),
|
|
6933
|
-
((
|
|
6716
|
+
((_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 })); })))));
|
|
6934
6717
|
}
|
|
6935
6718
|
LayerListItem.defaultProps = {
|
|
6936
6719
|
type: 'layer',
|
|
@@ -6939,26 +6722,510 @@ LayerListItem.defaultProps = {
|
|
|
6939
6722
|
buttons: React__default["default"].createElement(React__default["default"].Fragment, null),
|
|
6940
6723
|
};
|
|
6941
6724
|
|
|
6942
|
-
var
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6725
|
+
var sketchTools = [
|
|
6726
|
+
{ name: 'Point', mode: 'draw_point', icon: React__default["default"].createElement(ScatterPlotIcon__default["default"], null) },
|
|
6727
|
+
{ name: 'LineString', mode: 'draw_line_string', icon: React__default["default"].createElement(PolylineIcon__default["default"], null) },
|
|
6728
|
+
{ name: 'Polygon', mode: 'draw_polygon', icon: React__default["default"].createElement(PentagonIcon__default["default"], null) },
|
|
6729
|
+
];
|
|
6730
|
+
/**
|
|
6731
|
+
* Component template
|
|
6732
|
+
*
|
|
6733
|
+
*/
|
|
6734
|
+
var MlSketchTool = function (props) {
|
|
6951
6735
|
var _a, _b;
|
|
6952
|
-
var
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6736
|
+
var mapHook = useMap({
|
|
6737
|
+
mapId: props.mapId,
|
|
6738
|
+
waitForLayer: props.insertBeforeLayer,
|
|
6739
|
+
});
|
|
6740
|
+
var _c = React.useState(), hoveredGeometry = _c[0], setHoveredGeometry = _c[1];
|
|
6741
|
+
var _d = React.useState({
|
|
6742
|
+
activeGeometryIndex: undefined,
|
|
6743
|
+
selectedGeoJson: undefined,
|
|
6744
|
+
geometries: [],
|
|
6745
|
+
drawMode: undefined,
|
|
6746
|
+
}), sketchState = _d[0], setSketchState = _d[1];
|
|
6747
|
+
var buttonStyle = __assign({}, props.buttonStyleOverride);
|
|
6748
|
+
var buttonClickHandler = function (buttonDrawMode) {
|
|
6749
|
+
setSketchState(function (_state) { return ({
|
|
6750
|
+
drawMode: _state.drawMode !== buttonDrawMode ? buttonDrawMode : undefined,
|
|
6751
|
+
geometries: _state.geometries,
|
|
6752
|
+
activeGeometryIndex: undefined,
|
|
6753
|
+
selectedGeoJson: undefined,
|
|
6754
|
+
}); });
|
|
6755
|
+
};
|
|
6756
|
+
var removeGeoJson = function (geoJson) {
|
|
6757
|
+
setSketchState(function (_sketchState) {
|
|
6758
|
+
var _geometries = __spreadArray([], _sketchState.geometries, true);
|
|
6759
|
+
_geometries.splice(_geometries.indexOf(geoJson), 1);
|
|
6760
|
+
return __assign(__assign({}, _sketchState), { geometries: _geometries, activeGeometryIndex: _sketchState.activeGeometryIndex
|
|
6761
|
+
? _sketchState.activeGeometryIndex - 1
|
|
6762
|
+
: undefined });
|
|
6763
|
+
});
|
|
6764
|
+
};
|
|
6765
|
+
var SketchToolButtons = function () {
|
|
6766
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, sketchTools.map(function (el) {
|
|
6767
|
+
var stateColor = function (theme) {
|
|
6768
|
+
if (sketchState.drawMode === el.mode) {
|
|
6769
|
+
return theme.palette.primary.main;
|
|
6770
|
+
}
|
|
6771
|
+
else {
|
|
6772
|
+
return theme.palette.navigation.navColor;
|
|
6773
|
+
}
|
|
6774
|
+
};
|
|
6775
|
+
var stateIconColor = function (theme) {
|
|
6776
|
+
if (sketchState.drawMode !== el.mode) {
|
|
6777
|
+
return theme.palette.primary.main;
|
|
6778
|
+
}
|
|
6779
|
+
else {
|
|
6780
|
+
return theme.palette.navigation.navColor;
|
|
6781
|
+
}
|
|
6782
|
+
};
|
|
6783
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6784
|
+
React__default["default"].createElement(Tooltip__default["default"], { title: el.name },
|
|
6785
|
+
React__default["default"].createElement(material.Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
6786
|
+
backgroundColor: stateColor,
|
|
6787
|
+
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
6788
|
+
})));
|
|
6789
|
+
};
|
|
6790
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6791
|
+
React__default["default"].createElement(system.Box, { sx: {
|
|
6792
|
+
zIndex: 104,
|
|
6793
|
+
} },
|
|
6794
|
+
React__default["default"].createElement(ButtonGroup__default["default"], null,
|
|
6795
|
+
React__default["default"].createElement(SketchToolButtons, null))),
|
|
6796
|
+
sketchState.drawMode && (React__default["default"].createElement(MlFeatureEditor, { mode: sketchState.drawMode, geojson: sketchState.selectedGeoJson, onChange: function (feature) {
|
|
6797
|
+
if (!(feature === null || feature === void 0 ? void 0 : feature[0]))
|
|
6798
|
+
return;
|
|
6799
|
+
setSketchState(function (_sketchState) {
|
|
6800
|
+
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
6801
|
+
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
6802
|
+
var tempFeature = feature[0];
|
|
6803
|
+
tempFeature.properties.id = tempFeature.id;
|
|
6804
|
+
_sketchState.activeGeometryIndex = _geometries.length;
|
|
6805
|
+
_geometries.push(tempFeature);
|
|
6806
|
+
}
|
|
6807
|
+
else {
|
|
6808
|
+
_geometries[_sketchState.activeGeometryIndex] = feature[0];
|
|
6809
|
+
}
|
|
6810
|
+
return __assign(__assign({}, _sketchState), { geometries: _geometries });
|
|
6811
|
+
});
|
|
6812
|
+
}, onFinish: function () {
|
|
6813
|
+
setSketchState(function (_sketchState) { return (__assign(__assign({}, _sketchState), { drawMode: undefined, activeGeometryIndex: undefined, selectedGeoJson: undefined })); });
|
|
6814
|
+
} })),
|
|
6815
|
+
React__default["default"].createElement(List__default["default"], { sx: { zIndex: 105 } },
|
|
6816
|
+
sketchState.geometries.map(function (el) { return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6817
|
+
React__default["default"].createElement(system.Box, { key: el.id, sx: { display: 'flex', flexDirection: 'column' } },
|
|
6818
|
+
React__default["default"].createElement("br", null),
|
|
6819
|
+
React__default["default"].createElement(system.Box, { flexDirection: 'row', sx: {
|
|
6820
|
+
'&:hover': {
|
|
6821
|
+
backgroundColor: 'rgb(177, 177, 177, 0.2)',
|
|
6822
|
+
},
|
|
6823
|
+
}, onMouseOver: function () {
|
|
6824
|
+
setHoveredGeometry(el);
|
|
6825
|
+
}, onMouseLeave: function () {
|
|
6826
|
+
setHoveredGeometry(undefined);
|
|
6827
|
+
} },
|
|
6828
|
+
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 }),
|
|
6829
|
+
React__default["default"].createElement(system.Box, { sx: {
|
|
6830
|
+
padding: '3px 30px',
|
|
6831
|
+
} },
|
|
6832
|
+
React__default["default"].createElement(ButtonGroup__default["default"], { size: "small" },
|
|
6833
|
+
React__default["default"].createElement(material.Button, { onClick: function () {
|
|
6834
|
+
var _a;
|
|
6835
|
+
(_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setCenter(el.geometry.type === 'Point'
|
|
6836
|
+
? el.geometry.coordinates
|
|
6837
|
+
: turf__namespace.centerOfMass(el).geometry.coordinates);
|
|
6838
|
+
} },
|
|
6839
|
+
React__default["default"].createElement(GpsFixedIcon__default["default"], null)),
|
|
6840
|
+
React__default["default"].createElement(material.Button, { sx: buttonStyle, onClick: function () {
|
|
6841
|
+
setSketchState(function (_sketchState) { return (__assign(__assign({}, _sketchState), { selectedGeoJson: el, activeGeometryIndex: _sketchState.geometries.indexOf(el), drawMode: 'simple_select' })); });
|
|
6842
|
+
} },
|
|
6843
|
+
React__default["default"].createElement(EditIcon__default["default"], null)),
|
|
6844
|
+
React__default["default"].createElement(material.Button, { sx: buttonStyle, onClick: function () {
|
|
6845
|
+
removeGeoJson(el);
|
|
6846
|
+
setHoveredGeometry(undefined);
|
|
6847
|
+
} },
|
|
6848
|
+
React__default["default"].createElement(DeleteIcon__default["default"], null)))))))); }),
|
|
6849
|
+
hoveredGeometry && (React__default["default"].createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: { type: 'FeatureCollection', features: [hoveredGeometry] }, type: 'line', layerId: 'highlightBorder', paint: {
|
|
6850
|
+
'line-color': '#dd9900',
|
|
6851
|
+
'line-opacity': 0.4,
|
|
6852
|
+
'line-width': 10,
|
|
6853
|
+
} }))),
|
|
6854
|
+
sketchState.drawMode === 'simple_select' && (React__default["default"].createElement(material.Typography, { sx: { fontSize: '0.6em' } },
|
|
6855
|
+
"Edit ", (_b = (_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.geometry) === null || _b === void 0 ? void 0 :
|
|
6856
|
+
_b.type))));
|
|
6857
|
+
};
|
|
6858
|
+
MlSketchTool.defaultProps = {
|
|
6859
|
+
mapId: undefined,
|
|
6860
|
+
buttonStyleOverride: {},
|
|
6861
|
+
};
|
|
6862
|
+
|
|
6863
|
+
/**
|
|
6864
|
+
* Component template
|
|
6865
|
+
*
|
|
6866
|
+
*/
|
|
6867
|
+
var useCameraFollowPath = function (props) {
|
|
6868
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
6869
|
+
// without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
|
|
6870
|
+
var initializedRef = React.useRef(false);
|
|
6871
|
+
var pause = React.useRef(props.pause);
|
|
6872
|
+
var zoom = React.useRef(props.zoom);
|
|
6873
|
+
var pitch = React.useRef(props.pitch);
|
|
6874
|
+
var step = React.useRef(1);
|
|
6875
|
+
var speed = React.useRef(props.speed);
|
|
6876
|
+
var timeoutId = React.useRef();
|
|
6877
|
+
var kmPerStep = props.kmPerStep || 0.01;
|
|
6878
|
+
var routeDistance = turf__namespace.lineDistance(props.route);
|
|
6879
|
+
var stepDuration = props.stepDuration || 70;
|
|
6880
|
+
var mapHook = useMap({
|
|
6881
|
+
mapId: props.mapId,
|
|
6882
|
+
waitForLayer: props.insertBeforeLayer,
|
|
6883
|
+
});
|
|
6884
|
+
React.useEffect(function () {
|
|
6885
|
+
pause.current = props.pause;
|
|
6886
|
+
if (!pause.current) {
|
|
6887
|
+
play();
|
|
6888
|
+
}
|
|
6889
|
+
}, [props.pause]);
|
|
6890
|
+
React.useEffect(function () {
|
|
6891
|
+
if (!mapHook.map)
|
|
6892
|
+
return;
|
|
6893
|
+
zoom.current = props.zoom;
|
|
6894
|
+
if (typeof zoom.current !== 'undefined' && mapHook.map.map.getZoom() !== zoom.current) {
|
|
6895
|
+
mapHook.map.map.setZoom(zoom.current);
|
|
6896
|
+
}
|
|
6897
|
+
}, [mapHook.map, props.zoom]);
|
|
6898
|
+
React.useEffect(function () {
|
|
6899
|
+
if (!mapHook.map)
|
|
6900
|
+
return;
|
|
6901
|
+
pitch.current = props.pitch;
|
|
6902
|
+
if (typeof pitch.current !== 'undefined' && pitch.current !== mapHook.map.map.getPitch()) {
|
|
6903
|
+
mapHook.map.map.setPitch(pitch.current);
|
|
6904
|
+
}
|
|
6905
|
+
}, [mapHook.map, props.pitch]);
|
|
6906
|
+
React.useEffect(function () {
|
|
6907
|
+
speed.current = props.speed;
|
|
6908
|
+
}, [props.speed]);
|
|
6909
|
+
var disableInteractivity = React.useCallback(function () {
|
|
6910
|
+
if (!mapHook.map)
|
|
6911
|
+
return;
|
|
6912
|
+
mapHook.map.map['scrollZoom'].disable();
|
|
6913
|
+
mapHook.map.map['boxZoom'].disable();
|
|
6914
|
+
mapHook.map.map['dragRotate'].disable();
|
|
6915
|
+
mapHook.map.map['dragPan'].disable();
|
|
6916
|
+
mapHook.map.map['keyboard'].disable();
|
|
6917
|
+
mapHook.map.map['doubleClickZoom'].disable();
|
|
6918
|
+
mapHook.map.map['touchZoomRotate'].disable();
|
|
6919
|
+
}, [mapHook.map]);
|
|
6920
|
+
var enableInteractivity = React.useCallback(function () {
|
|
6921
|
+
if (!mapHook.map)
|
|
6922
|
+
return;
|
|
6923
|
+
mapHook.map.map['scrollZoom'].enable();
|
|
6924
|
+
mapHook.map.map['boxZoom'].enable();
|
|
6925
|
+
mapHook.map.map['dragRotate'].enable();
|
|
6926
|
+
mapHook.map.map['dragPan'].enable();
|
|
6927
|
+
mapHook.map.map['keyboard'].enable();
|
|
6928
|
+
mapHook.map.map['doubleClickZoom'].enable();
|
|
6929
|
+
mapHook.map.map['touchZoomRotate'].enable();
|
|
6930
|
+
}, [mapHook.map]);
|
|
6931
|
+
function centerRoute() {
|
|
6932
|
+
if (!mapHook.map || !props.route)
|
|
6933
|
+
return;
|
|
6934
|
+
var bbox = turf__namespace.bbox(props.route);
|
|
6935
|
+
var bounds;
|
|
6936
|
+
if (bbox && bbox.length > 3) {
|
|
6937
|
+
bounds = [
|
|
6938
|
+
[bbox[0], bbox[1]],
|
|
6939
|
+
[bbox[2], bbox[3]],
|
|
6940
|
+
];
|
|
6941
|
+
mapHook.map.map.fitBounds(bounds, { padding: 100 });
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
function play() {
|
|
6945
|
+
if (!mapHook.map)
|
|
6946
|
+
return;
|
|
6947
|
+
if (!pause.current) {
|
|
6948
|
+
disableInteractivity();
|
|
6949
|
+
if (typeof zoom.current !== 'undefined' && mapHook.map.map.getZoom() !== zoom.current) {
|
|
6950
|
+
mapHook.map.map.setZoom(zoom.current);
|
|
6951
|
+
}
|
|
6952
|
+
var alongRoutelati = turf__namespace.along(props.route, step.current * kmPerStep).geometry
|
|
6953
|
+
.coordinates;
|
|
6954
|
+
if (step.current * kmPerStep < routeDistance) {
|
|
6955
|
+
mapHook.map.map.easeTo({
|
|
6956
|
+
center: alongRoutelati,
|
|
6957
|
+
bearing: turf__namespace.bearing(turf__namespace.point([mapHook.map.map.getCenter().lng, mapHook.map.map.getCenter().lat]), turf__namespace.point(alongRoutelati)),
|
|
6958
|
+
duration: stepDuration,
|
|
6959
|
+
essential: true,
|
|
6960
|
+
});
|
|
6961
|
+
if (typeof speed.current !== 'undefined') {
|
|
6962
|
+
step.current = step.current + speed.current;
|
|
6963
|
+
}
|
|
6964
|
+
else {
|
|
6965
|
+
step.current++;
|
|
6966
|
+
}
|
|
6967
|
+
console.log('PAN MOVE');
|
|
6968
|
+
setTimeout(function () {
|
|
6969
|
+
play();
|
|
6970
|
+
}, 100);
|
|
6971
|
+
}
|
|
6972
|
+
else {
|
|
6973
|
+
mapHook.map.map.setPitch(0);
|
|
6974
|
+
centerRoute();
|
|
6975
|
+
enableInteractivity();
|
|
6976
|
+
console.log('ENABLE CONTROLS');
|
|
6977
|
+
step.current = 1;
|
|
6978
|
+
}
|
|
6979
|
+
}
|
|
6980
|
+
else {
|
|
6981
|
+
enableInteractivity();
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
function reset() {
|
|
6985
|
+
if (!mapHook.map)
|
|
6986
|
+
return;
|
|
6987
|
+
centerRoute();
|
|
6988
|
+
enableInteractivity();
|
|
6989
|
+
step.current = 1;
|
|
6990
|
+
}
|
|
6991
|
+
React.useEffect(function () {
|
|
6992
|
+
if (!mapHook.map || initializedRef.current)
|
|
6993
|
+
return;
|
|
6994
|
+
initializedRef.current = true;
|
|
6995
|
+
centerRoute();
|
|
6996
|
+
}, [mapHook.map]);
|
|
6997
|
+
React.useEffect(function () {
|
|
6998
|
+
return function () {
|
|
6999
|
+
if (timeoutId.current) {
|
|
7000
|
+
clearTimeout(timeoutId.current);
|
|
7001
|
+
}
|
|
7002
|
+
};
|
|
7003
|
+
}, []);
|
|
7004
|
+
return {
|
|
7005
|
+
play: play,
|
|
7006
|
+
reset: reset,
|
|
7007
|
+
};
|
|
7008
|
+
};
|
|
7009
|
+
useCameraFollowPath.defaultProps = {
|
|
7010
|
+
mapId: undefined,
|
|
7011
|
+
zoom: 18,
|
|
7012
|
+
};
|
|
7013
|
+
|
|
7014
|
+
function useLayerFilter(props) {
|
|
7015
|
+
var mapHook = useMap({ mapId: props.mapId });
|
|
7016
|
+
React.useEffect(function () {
|
|
7017
|
+
if (!mapHook.map || !props.layerId || !props.filter)
|
|
7018
|
+
return;
|
|
7019
|
+
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
7020
|
+
var _layerId_1 = props.layerId;
|
|
7021
|
+
mapHook.map.map.setFilter(_layerId_1, props.filter);
|
|
7022
|
+
return function () {
|
|
7023
|
+
if (mapHook.map) {
|
|
7024
|
+
mapHook.map.map.setFilter(_layerId_1, null);
|
|
7025
|
+
}
|
|
7026
|
+
};
|
|
7027
|
+
}
|
|
7028
|
+
return;
|
|
7029
|
+
}, [props, mapHook.map]);
|
|
7030
|
+
return {};
|
|
7031
|
+
}
|
|
7032
|
+
|
|
7033
|
+
var touchEquivalents = {
|
|
7034
|
+
mousedown: 'touchstart',
|
|
7035
|
+
mouseup: 'touchend',
|
|
7036
|
+
mousemove: 'touchmove'
|
|
7037
|
+
};
|
|
7038
|
+
var touchEquivalentsKeys = Object.keys(touchEquivalents);
|
|
7039
|
+
function useLayerEvent(props) {
|
|
7040
|
+
var mapState = useMapState({
|
|
7041
|
+
mapId: props.mapId,
|
|
7042
|
+
watch: {
|
|
7043
|
+
layers: true
|
|
7044
|
+
}
|
|
7045
|
+
});
|
|
7046
|
+
var mapHook = useMap({
|
|
7047
|
+
mapId: props.mapId
|
|
7048
|
+
});
|
|
7049
|
+
React.useEffect(function () {
|
|
7050
|
+
if (!mapHook.map) return true;
|
|
7051
|
+
if (typeof props.condition !== 'undefined' && props.condition === false) return;
|
|
7052
|
+
//console.log('useLayerEvent');
|
|
7053
|
+
//console.log(mapState);
|
|
7054
|
+
|
|
7055
|
+
if (mapHook.map.map.getLayer(props.layerId)) {
|
|
7056
|
+
//console.log("layer avail");
|
|
7057
|
+
var _event = props.event;
|
|
7058
|
+
var _layerId = props.layerId;
|
|
7059
|
+
var _eventHandler = props.eventHandler;
|
|
7060
|
+
|
|
7061
|
+
//console.log(_event);
|
|
7062
|
+
mapHook.map.on(_event, _layerId, _eventHandler, mapHook.componentId);
|
|
7063
|
+
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
7064
|
+
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
7065
|
+
mapHook.map.on(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
return function () {
|
|
7069
|
+
mapHook.map.off(_event, _layerId, _eventHandler);
|
|
7070
|
+
if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
|
|
7071
|
+
if (touchEquivalentsKeys.indexOf(_event) !== -1) {
|
|
7072
|
+
mapHook.map.off(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
|
|
7073
|
+
}
|
|
7074
|
+
}
|
|
7075
|
+
};
|
|
7076
|
+
}
|
|
7077
|
+
}, [props, mapState, mapHook.map]);
|
|
7078
|
+
return {};
|
|
7079
|
+
}
|
|
7080
|
+
|
|
7081
|
+
var useLayerContext = function () {
|
|
7082
|
+
var layerContext = React.useContext(LayerContext);
|
|
7083
|
+
return layerContext;
|
|
7084
|
+
};
|
|
7085
|
+
|
|
7086
|
+
/**
|
|
7087
|
+
* Enables the use of custom protocols (basically custom tile load functions) in the maplibre-gl-js library.
|
|
7088
|
+
*
|
|
7089
|
+
*/
|
|
7090
|
+
var useAddProtocol = function (props) {
|
|
7091
|
+
React.useEffect(function () {
|
|
7092
|
+
if (!props.protocol || typeof props.handler !== 'function')
|
|
7093
|
+
return;
|
|
7094
|
+
maplibregl__default["default"].addProtocol(props.protocol, props.handler);
|
|
7095
|
+
return function () {
|
|
7096
|
+
maplibregl__default["default"].removeProtocol(props.protocol);
|
|
7097
|
+
};
|
|
7098
|
+
}, [props]);
|
|
7099
|
+
return {};
|
|
7100
|
+
};
|
|
7101
|
+
useAddProtocol.defaultProps = {
|
|
7102
|
+
mapId: undefined,
|
|
7103
|
+
};
|
|
7104
|
+
|
|
7105
|
+
var SimpleDataContext = /*#__PURE__*/React__default["default"].createContext({});
|
|
7106
|
+
var SimpleDataContextProvider = SimpleDataContext.Provider;
|
|
7107
|
+
|
|
7108
|
+
var SimpleDataProvider = function SimpleDataProvider(props) {
|
|
7109
|
+
var _useState = React.useState(null),
|
|
7110
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7111
|
+
data = _useState2[0],
|
|
7112
|
+
setData = _useState2[1];
|
|
7113
|
+
React.useEffect(function () {
|
|
7114
|
+
if (!props.url) return;
|
|
7115
|
+
var data_promise = null;
|
|
7116
|
+
if (props.format === "json") {
|
|
7117
|
+
data_promise = d3__namespace.json(props.url);
|
|
7118
|
+
} else if (props.format === "csv") {
|
|
7119
|
+
data_promise = d3__namespace.csv(props.url);
|
|
7120
|
+
} else if (props.format === "xml") {
|
|
7121
|
+
data_promise = d3__namespace.xml(props.url);
|
|
7122
|
+
}
|
|
7123
|
+
if (data_promise) {
|
|
7124
|
+
data_promise.then(function (received_data) {
|
|
7125
|
+
if (props.format === "xml") {
|
|
7126
|
+
if (props.nodeType) {
|
|
7127
|
+
var dataTmp = [];
|
|
7128
|
+
received_data.querySelectorAll(props.nodeType).forEach(function (el) {
|
|
7129
|
+
dataTmp.push(props.formatData(el));
|
|
7130
|
+
});
|
|
7131
|
+
setData(dataTmp);
|
|
7132
|
+
}
|
|
7133
|
+
} else {
|
|
7134
|
+
if (props.data_property) {
|
|
7135
|
+
received_data = received_data[props.data_property];
|
|
7136
|
+
}
|
|
7137
|
+
if (typeof props.formatData === "function") {
|
|
7138
|
+
setData(received_data.map(props.formatData));
|
|
7139
|
+
} else {
|
|
7140
|
+
setData(received_data);
|
|
7141
|
+
}
|
|
7142
|
+
}
|
|
7143
|
+
if (typeof props.onData === "function") {
|
|
7144
|
+
props.onData();
|
|
7145
|
+
}
|
|
7146
|
+
});
|
|
7147
|
+
}
|
|
7148
|
+
}, [props.url, props]);
|
|
7149
|
+
var value = {
|
|
7150
|
+
data: data,
|
|
7151
|
+
setData: setData
|
|
7152
|
+
};
|
|
7153
|
+
return /*#__PURE__*/React__default["default"].createElement(SimpleDataContextProvider, {
|
|
7154
|
+
value: value
|
|
7155
|
+
}, props.children);
|
|
7156
|
+
};
|
|
7157
|
+
SimpleDataProvider.propTypes = {
|
|
7158
|
+
children: PropTypes__default["default"].node.isRequired
|
|
7159
|
+
};
|
|
7160
|
+
|
|
7161
|
+
var ListStyled = material.styled(material.List)({
|
|
7162
|
+
marginTop: '15px',
|
|
7163
|
+
});
|
|
7164
|
+
function LayerList(props) {
|
|
7165
|
+
return React__default["default"].createElement(ListStyled, null, props === null || props === void 0 ? void 0 : props.children);
|
|
7166
|
+
}
|
|
7167
|
+
|
|
7168
|
+
var IconButtonStyled = material.styled(material.IconButton)({
|
|
7169
|
+
padding: '4px',
|
|
7170
|
+
marginTop: '-3px',
|
|
7171
|
+
background: 'none',
|
|
7172
|
+
'&:hover': {
|
|
7173
|
+
background: 'none',
|
|
7174
|
+
},
|
|
7175
|
+
});
|
|
7176
|
+
function LayerListItemFactory(props) {
|
|
7177
|
+
var _a, _b;
|
|
7178
|
+
var layerContext = useLayerContext();
|
|
7179
|
+
var mapHook = useMap({ mapId: undefined });
|
|
7180
|
+
//useCallback Hook
|
|
7181
|
+
function fitLayer(layer) {
|
|
7182
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
7183
|
+
var layerSource = layer.id && ((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.getLayer(layer.id)) === null || _b === void 0 ? void 0 : _b.source)
|
|
7184
|
+
? (_c = mapHook.map) === null || _c === void 0 ? void 0 : _c.getLayer(layer.id).source
|
|
7185
|
+
: undefined;
|
|
7186
|
+
var _bbox = null;
|
|
7187
|
+
switch (layer.type) {
|
|
7188
|
+
case 'geojson':
|
|
7189
|
+
if ((_d = layer.config) === null || _d === void 0 ? void 0 : _d.geojson) {
|
|
7190
|
+
(_e = mapHook.map) === null || _e === void 0 ? void 0 : _e.fitBounds(turf.bbox((_f = layer.config) === null || _f === void 0 ? void 0 : _f.geojson), props.fitBoundsOptions);
|
|
7191
|
+
}
|
|
7192
|
+
else {
|
|
7193
|
+
if (!layerSource) {
|
|
7194
|
+
return;
|
|
7195
|
+
}
|
|
7196
|
+
var _geojson = {
|
|
7197
|
+
type: 'FeatureCollection',
|
|
7198
|
+
features: (_g = mapHook.map) === null || _g === void 0 ? void 0 : _g.querySourceFeatures(layerSource),
|
|
7199
|
+
};
|
|
7200
|
+
if (_geojson.features.length === 0) {
|
|
7201
|
+
(_h = mapHook.map) === null || _h === void 0 ? void 0 : _h.zoomTo(1);
|
|
7202
|
+
_geojson.features = (_j = mapHook.map) === null || _j === void 0 ? void 0 : _j.querySourceFeatures(layerSource);
|
|
7203
|
+
}
|
|
7204
|
+
_bbox = turf.bbox(_geojson);
|
|
7205
|
+
}
|
|
7206
|
+
break;
|
|
7207
|
+
case 'vt':
|
|
7208
|
+
console.log('vt');
|
|
7209
|
+
break;
|
|
7210
|
+
case 'wms':
|
|
7211
|
+
_bbox = (_o = (_m = (_l = (_k = layer === null || layer === void 0 ? void 0 : layer.config) === null || _k === void 0 ? void 0 : _k.config) === null || _l === void 0 ? void 0 : _l.layers) === null || _m === void 0 ? void 0 : _m[0]) === null || _o === void 0 ? void 0 : _o.EX_GeographicBoundingBox;
|
|
7212
|
+
break;
|
|
7213
|
+
default:
|
|
7214
|
+
return;
|
|
7215
|
+
}
|
|
7216
|
+
if (_bbox) {
|
|
7217
|
+
(_p = mapHook.map) === null || _p === void 0 ? void 0 : _p.fitBounds(_bbox, props.fitBoundsOptions);
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
var orderLayers = React.useMemo(function () {
|
|
7221
|
+
var layerIds = __spreadArray(__spreadArray([
|
|
7222
|
+
'order-background'
|
|
7223
|
+
], __spreadArray([], layerContext.layers, true).map(function (_el, idx) { return 'content_order_' + idx; }), true), [
|
|
7224
|
+
'order-labels',
|
|
7225
|
+
], false);
|
|
7226
|
+
return layerIds.reverse();
|
|
7227
|
+
}, [layerContext.layers]);
|
|
7228
|
+
var layers = React.useMemo(function () {
|
|
6962
7229
|
if (props.layers)
|
|
6963
7230
|
return props.layers;
|
|
6964
7231
|
if (layerContext === null || layerContext === void 0 ? void 0 : layerContext.layers)
|
|
@@ -6970,83 +7237,130 @@ function LayerListItemFactory(props) {
|
|
|
6970
7237
|
return props.setLayers;
|
|
6971
7238
|
return layerContext.setLayers;
|
|
6972
7239
|
}, [props.setLayers, layerContext.setLayers]);
|
|
7240
|
+
var pointerSensor = core.useSensor(core.PointerSensor, {
|
|
7241
|
+
activationConstraint: {
|
|
7242
|
+
distance: 5,
|
|
7243
|
+
},
|
|
7244
|
+
});
|
|
7245
|
+
var mouseSensor = core.useSensor(core.MouseSensor, {
|
|
7246
|
+
activationConstraint: {
|
|
7247
|
+
distance: 5,
|
|
7248
|
+
},
|
|
7249
|
+
});
|
|
7250
|
+
var sensors = core.useSensors(mouseSensor, pointerSensor);
|
|
7251
|
+
function dragEnd(event) {
|
|
7252
|
+
var _a, _b, _c;
|
|
7253
|
+
var dragLayerId = event.active.id;
|
|
7254
|
+
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;
|
|
7255
|
+
layerContext.moveLayer(String(dragLayerId), function () { return dragLayerNewPosition; });
|
|
7256
|
+
}
|
|
6973
7257
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6974
7258
|
React__default["default"].createElement(MlOrderLayers, { layerIds: orderLayers, insertBeforeLayer: "_background" }),
|
|
6975
7259
|
((_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) {
|
|
6976
7260
|
return layerContext.setSymbolLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
6977
7261
|
}, visible: true, configurable: true, type: "layer", name: "Labels" })),
|
|
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
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
React__default["default"].createElement(
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7262
|
+
React__default["default"].createElement(core.DndContext, { collisionDetection: core.closestCenter, sensors: sensors, onDragEnd: function (event) { return dragEnd(event); }, modifiers: [modifiers.restrictToVerticalAxis] },
|
|
7263
|
+
React__default["default"].createElement(sortable.SortableContext, { items: layers, strategy: sortable.verticalListSortingStrategy },
|
|
7264
|
+
__spreadArray([], layers, true).map(function (layer, idx) {
|
|
7265
|
+
var _a, _b, _c, _d, _e;
|
|
7266
|
+
if (!(layer === null || layer === void 0 ? void 0 : layer.id))
|
|
7267
|
+
return null;
|
|
7268
|
+
switch (layer.type) {
|
|
7269
|
+
case 'geojson':
|
|
7270
|
+
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,
|
|
7271
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === layers.length - 1, onClick: function () {
|
|
7272
|
+
layerContext.moveDown(layer.id || '');
|
|
7273
|
+
} },
|
|
7274
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleDown, null)),
|
|
7275
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === 0, onClick: function () {
|
|
7276
|
+
layerContext.moveUp(layer.id || '');
|
|
7277
|
+
} },
|
|
7278
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleUp, null)),
|
|
7279
|
+
React__default["default"].createElement(IconButtonStyled, { onClick: function () { return fitLayer(layer); } },
|
|
7280
|
+
React__default["default"].createElement(iconsMaterial.CenterFocusWeak, null))), setLayerState: function (layerConfig) {
|
|
7281
|
+
return setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7282
|
+
var _layers = __spreadArray([], current, true);
|
|
7283
|
+
if (layerConfig === false) {
|
|
7284
|
+
_layers.splice(idx, 1);
|
|
7285
|
+
}
|
|
7286
|
+
else {
|
|
7287
|
+
_layers[idx].config = layerConfig;
|
|
7288
|
+
}
|
|
7289
|
+
return _layers;
|
|
7290
|
+
});
|
|
7291
|
+
}, configurable: true, showDeleteButton: true }));
|
|
7292
|
+
case 'wms':
|
|
7293
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7294
|
+
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) {
|
|
7295
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7296
|
+
var _layers = __spreadArray([], current, true);
|
|
7297
|
+
if (layerConfig === false) {
|
|
7298
|
+
_layers.splice(idx, 1);
|
|
7299
|
+
}
|
|
7300
|
+
else {
|
|
7301
|
+
_layers[idx].config.config = layerConfig;
|
|
7302
|
+
}
|
|
7303
|
+
return _layers;
|
|
7304
|
+
});
|
|
7305
|
+
}, featureInfoActive: ((_b = layer === null || layer === void 0 ? void 0 : layer.config) === null || _b === void 0 ? void 0 : _b.featureInfoActive) || false, setFeatureInfoActive: function (updateFunction) {
|
|
7306
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7307
|
+
var _a;
|
|
7308
|
+
var _layers = __spreadArray([], current, true);
|
|
7309
|
+
if (typeof updateFunction === 'function') {
|
|
7310
|
+
_layers[idx].config.featureInfoActive =
|
|
7311
|
+
updateFunction(((_a = _layers[idx].config) === null || _a === void 0 ? void 0 : _a.featureInfoActive) ||
|
|
7312
|
+
false);
|
|
7313
|
+
}
|
|
7314
|
+
return _layers;
|
|
7315
|
+
});
|
|
7316
|
+
}, showDeleteButton: true, buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7317
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === layers.length - 1, onClick: function () {
|
|
7318
|
+
layerContext.moveDown(layer.id || '');
|
|
7319
|
+
} },
|
|
7320
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleDown, null)),
|
|
7321
|
+
React__default["default"].createElement(IconButtonStyled, { disabled: idx === 0, onClick: function () {
|
|
7322
|
+
layerContext.moveUp(layer.id || '');
|
|
7323
|
+
} },
|
|
7324
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleUp, null)),
|
|
7325
|
+
React__default["default"].createElement(IconButtonStyled, { onClick: function () { return fitLayer(layer); } },
|
|
7326
|
+
React__default["default"].createElement(iconsMaterial.CenterFocusWeak, null))) }))));
|
|
7327
|
+
case 'vt':
|
|
7328
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, { key: (layer === null || layer === void 0 ? void 0 : layer.id) + '_listItem' },
|
|
7329
|
+
React__default["default"].createElement(LayerListItem, { key: layer.id, name: (layer === null || layer === void 0 ? void 0 : layer.name) || (layer === null || layer === void 0 ? void 0 : layer.type) + ' layer' || 'unnamed layer', layerComponent: React__default["default"].createElement(MlVectorTileLayer, { layers: ((_c = layer === null || layer === void 0 ? void 0 : layer.config) === null || _c === void 0 ? void 0 : _c.layers) || [], key: layer.id, mapId: layer === null || layer === void 0 ? void 0 : layer.config.mapId, sourceOptions: (_d = layer === null || layer === void 0 ? void 0 : layer.config) === null || _d === void 0 ? void 0 : _d.sourceOptions, layerId: layer.id, url: (_e = layer === null || layer === void 0 ? void 0 : layer.config) === null || _e === void 0 ? void 0 : _e.url }), buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7330
|
+
React__default["default"].createElement(IconButtonStyled, { key: layer.id + '_button1', disabled: idx === layers.length - 1, onClick: function () {
|
|
7331
|
+
layerContext.moveDown(layer.id || '');
|
|
7332
|
+
} },
|
|
7333
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleDown, null)),
|
|
7334
|
+
React__default["default"].createElement(IconButtonStyled, { key: layer.id + '_button2', disabled: idx === 0, onClick: function () {
|
|
7335
|
+
layerContext.moveUp(layer.id || '');
|
|
7336
|
+
} },
|
|
7337
|
+
React__default["default"].createElement(iconsMaterial.ArrowCircleUp, null)),
|
|
7338
|
+
React__default["default"].createElement(IconButtonStyled, { onClick: function () { return fitLayer(layer); } },
|
|
7339
|
+
React__default["default"].createElement(iconsMaterial.CenterFocusWeak, null))), setLayerState: function (layerConfig) {
|
|
7340
|
+
return setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7341
|
+
var _layers = __spreadArray([], current, true);
|
|
7342
|
+
if (layerConfig === false) {
|
|
7343
|
+
_layers.splice(idx, 1);
|
|
7344
|
+
}
|
|
7345
|
+
else {
|
|
7346
|
+
_layers[idx].config = layerConfig;
|
|
7347
|
+
}
|
|
7348
|
+
return _layers;
|
|
7349
|
+
});
|
|
7350
|
+
}, configurable: true, showDeleteButton: true })));
|
|
7351
|
+
default:
|
|
7352
|
+
return null;
|
|
7353
|
+
}
|
|
7354
|
+
}),
|
|
7355
|
+
((_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) {
|
|
7356
|
+
layerContext.setBackgroundLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
7357
|
+
}, visible: true, configurable: true, type: "layer", name: "Background" }))))));
|
|
7044
7358
|
}
|
|
7045
7359
|
LayerListItemFactory.defaultProps = {
|
|
7046
7360
|
mapId: undefined,
|
|
7047
7361
|
};
|
|
7048
7362
|
|
|
7049
|
-
var types = [
|
|
7363
|
+
var types$1 = [
|
|
7050
7364
|
'fill',
|
|
7051
7365
|
'line',
|
|
7052
7366
|
'circle',
|
|
@@ -7064,7 +7378,7 @@ function GeoJsonLayerForm(props) {
|
|
|
7064
7378
|
React__default["default"].createElement(material.InputLabel, { id: "type-label" }, "Type"),
|
|
7065
7379
|
React__default["default"].createElement(material.Select, { labelId: "type-label", value: config.type, label: "Type", onChange: function (ev) {
|
|
7066
7380
|
return setConfig(function (current) { return (__assign(__assign({}, current), { type: ev.target.value })); });
|
|
7067
|
-
} }, types.map(function (type) { return (React__default["default"].createElement(material.MenuItem, { key: type, value: type }, type)); }))),
|
|
7381
|
+
} }, types$1.map(function (type) { return (React__default["default"].createElement(material.MenuItem, { key: type, value: type }, type)); }))),
|
|
7068
7382
|
React__default["default"].createElement(material.FormControl, { fullWidth: true },
|
|
7069
7383
|
React__default["default"].createElement(material.Button, { variant: "contained", component: "label", sx: { marginTop: '10px' } },
|
|
7070
7384
|
"Upload File",
|
|
@@ -7079,11 +7393,10 @@ function GeoJsonLayerForm(props) {
|
|
|
7079
7393
|
React__default["default"].createElement(material.Button, { disabled: !configIsValid, onClick: function () { return props.onSubmit(config); } }, "Add"))));
|
|
7080
7394
|
}
|
|
7081
7395
|
|
|
7082
|
-
var layerTypes = ['geojson', 'wms'];
|
|
7083
7396
|
var LayerTypeForm = function (props) {
|
|
7084
7397
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7085
|
-
React__default["default"].createElement(material.DialogTitle, null, "Select a layer type"),
|
|
7086
|
-
React__default["default"].createElement(material.List, null, layerTypes.map(function (type) { return (React__default["default"].createElement(material.ListItem, { disableGutters: true, key:
|
|
7398
|
+
React__default["default"].createElement(material.DialogTitle, null, props.layerTypes.length > 1 ? "Select a layer type" : "Load new layer"),
|
|
7399
|
+
React__default["default"].createElement(material.List, null, props.layerTypes.map(function (type, idx) { return (React__default["default"].createElement(material.ListItem, { disableGutters: true, key: idx },
|
|
7087
7400
|
React__default["default"].createElement(material.ListItemButton, { autoFocus: true, onClick: function () {
|
|
7088
7401
|
props.onSelect(type);
|
|
7089
7402
|
} },
|
|
@@ -7112,18 +7425,667 @@ function WmsLayerForm(props) {
|
|
|
7112
7425
|
React__default["default"].createElement(material.Button, { disabled: !configIsValid, onClick: function () { return props.onSubmit(config); } }, "Add"))));
|
|
7113
7426
|
}
|
|
7114
7427
|
|
|
7428
|
+
var optionFields$1 = ['latfield', 'lonfield', 'delimiter'];
|
|
7429
|
+
function CSVOptionsFormular(props) {
|
|
7430
|
+
var _a = React.useState(false), open = _a[0], setOpen = _a[1];
|
|
7431
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7432
|
+
React__default["default"].createElement(material.Typography, null, " Options "),
|
|
7433
|
+
React__default["default"].createElement(material.Button, { onClick: function () { return setOpen(!open); } }, open ? React__default["default"].createElement(IndeterminateCheckBoxIcon__default["default"], null) : React__default["default"].createElement(AddBoxIcon__default["default"], null)),
|
|
7434
|
+
React__default["default"].createElement(material.List, null, open &&
|
|
7435
|
+
(optionFields$1 === null || optionFields$1 === void 0 ? void 0 : optionFields$1.map(function (el) {
|
|
7436
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7437
|
+
React__default["default"].createElement(material.ListItem, null,
|
|
7438
|
+
React__default["default"].createElement(material.Typography, null,
|
|
7439
|
+
" ",
|
|
7440
|
+
el,
|
|
7441
|
+
" ")),
|
|
7442
|
+
React__default["default"].createElement(material.ListItem, null,
|
|
7443
|
+
React__default["default"].createElement(material.TextField, { size: "small", onChange: function (ev) {
|
|
7444
|
+
var newObject = {};
|
|
7445
|
+
newObject[el] = ev.target.value;
|
|
7446
|
+
props.setter(newObject);
|
|
7447
|
+
} }))));
|
|
7448
|
+
})))));
|
|
7449
|
+
}
|
|
7450
|
+
|
|
7451
|
+
var optionFields = [
|
|
7452
|
+
'completeFeature',
|
|
7453
|
+
'allFeatures',
|
|
7454
|
+
'renderTagged',
|
|
7455
|
+
'excludeWay',
|
|
7456
|
+
'suppressWay',
|
|
7457
|
+
];
|
|
7458
|
+
function OsmOptionsFomular(props) {
|
|
7459
|
+
var _a = React.useState(false), open = _a[0], setOpen = _a[1];
|
|
7460
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7461
|
+
React__default["default"].createElement(material.Typography, null, " Options "),
|
|
7462
|
+
React__default["default"].createElement(material.Button, { onClick: function () { return setOpen(!open); } }, open ? React__default["default"].createElement(IndeterminateCheckBoxIcon__default["default"], null) : React__default["default"].createElement(AddBoxIcon__default["default"], null)),
|
|
7463
|
+
React__default["default"].createElement(material.List, null, open &&
|
|
7464
|
+
(optionFields === null || optionFields === void 0 ? void 0 : optionFields.map(function (el) {
|
|
7465
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7466
|
+
React__default["default"].createElement(material.ListItem, null,
|
|
7467
|
+
React__default["default"].createElement(material.Typography, null,
|
|
7468
|
+
" ",
|
|
7469
|
+
el,
|
|
7470
|
+
" "),
|
|
7471
|
+
React__default["default"].createElement(material.Checkbox, { onChange: function (ev) {
|
|
7472
|
+
var newObject = {};
|
|
7473
|
+
newObject[el] = ev.target.value === 'on' ? true : false;
|
|
7474
|
+
props.setter(newObject);
|
|
7475
|
+
} }))));
|
|
7476
|
+
})))));
|
|
7477
|
+
}
|
|
7478
|
+
|
|
7479
|
+
function protocolPathParser(url) {
|
|
7480
|
+
var test = url.split('?');
|
|
7481
|
+
var urlParts = test[0].split('://');
|
|
7482
|
+
var protocolId = urlParts[0];
|
|
7483
|
+
var csvUrl = urlParts.length > 2 ? urlParts[1] + '://' + urlParts[2] : urlParts[1];
|
|
7484
|
+
var csvParts = csvUrl.split('/');
|
|
7485
|
+
var filename = csvParts.join('/');
|
|
7486
|
+
var optionsString = decodeURI(test[1]);
|
|
7487
|
+
var options = Object.fromEntries(new URLSearchParams(optionsString));
|
|
7488
|
+
return {
|
|
7489
|
+
protocolId: protocolId,
|
|
7490
|
+
filename: filename,
|
|
7491
|
+
options: options,
|
|
7492
|
+
};
|
|
7493
|
+
}
|
|
7494
|
+
|
|
7495
|
+
function getProtocolData(path) {
|
|
7496
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7497
|
+
var response, rawData, error_1;
|
|
7498
|
+
return __generator(this, function (_a) {
|
|
7499
|
+
switch (_a.label) {
|
|
7500
|
+
case 0:
|
|
7501
|
+
_a.trys.push([0, 3, , 4]);
|
|
7502
|
+
return [4 /*yield*/, fetch(path)];
|
|
7503
|
+
case 1:
|
|
7504
|
+
response = _a.sent();
|
|
7505
|
+
return [4 /*yield*/, response.text()];
|
|
7506
|
+
case 2:
|
|
7507
|
+
rawData = _a.sent();
|
|
7508
|
+
return [2 /*return*/, rawData];
|
|
7509
|
+
case 3:
|
|
7510
|
+
error_1 = _a.sent();
|
|
7511
|
+
console.error('File could not be loaded: ', error_1);
|
|
7512
|
+
return [2 /*return*/, error_1];
|
|
7513
|
+
case 4: return [2 /*return*/];
|
|
7514
|
+
}
|
|
7515
|
+
});
|
|
7516
|
+
});
|
|
7517
|
+
}
|
|
7518
|
+
|
|
7519
|
+
function convertCsv(filename, options) {
|
|
7520
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7521
|
+
var geojson;
|
|
7522
|
+
return __generator(this, function (_a) {
|
|
7523
|
+
switch (_a.label) {
|
|
7524
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
7525
|
+
var useOptions = options || {};
|
|
7526
|
+
var extension = filename.substring(filename.length - 3);
|
|
7527
|
+
if (extension === 'tsv') {
|
|
7528
|
+
options.delimiter = '\t';
|
|
7529
|
+
}
|
|
7530
|
+
getProtocolData(filename).then(function (rawData) {
|
|
7531
|
+
// Use the csv2geojson library to convert the CSV to GeoJSON
|
|
7532
|
+
csv2geojson__namespace.csv2geojson(rawData, useOptions, function (err, data) {
|
|
7533
|
+
if (err) {
|
|
7534
|
+
reject(err);
|
|
7535
|
+
}
|
|
7536
|
+
else {
|
|
7537
|
+
resolve(data);
|
|
7538
|
+
}
|
|
7539
|
+
});
|
|
7540
|
+
});
|
|
7541
|
+
})];
|
|
7542
|
+
case 1:
|
|
7543
|
+
geojson = _a.sent();
|
|
7544
|
+
return [2 /*return*/, geojson];
|
|
7545
|
+
}
|
|
7546
|
+
});
|
|
7547
|
+
});
|
|
7548
|
+
}
|
|
7549
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7550
|
+
var CSVProtocolHandler = function (params, callback) {
|
|
7551
|
+
var parsedParams = protocolPathParser(params.url);
|
|
7552
|
+
convertCsv(parsedParams.filename, parsedParams.options).then(function (data) {
|
|
7553
|
+
if (data !== undefined) {
|
|
7554
|
+
callback(null, data, null, null);
|
|
7555
|
+
}
|
|
7556
|
+
else {
|
|
7557
|
+
callback(new Error('CSV not found'));
|
|
7558
|
+
}
|
|
7559
|
+
});
|
|
7560
|
+
return { cancel: function () { } };
|
|
7561
|
+
};
|
|
7562
|
+
|
|
7563
|
+
function reduceFeatures(geojson) {
|
|
7564
|
+
var newFeatures = [];
|
|
7565
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7566
|
+
geojson.features.forEach(function (e) {
|
|
7567
|
+
if (!e.features) {
|
|
7568
|
+
newFeatures.push({
|
|
7569
|
+
type: e.type,
|
|
7570
|
+
geometry: e.geometry,
|
|
7571
|
+
properties: e.properties,
|
|
7572
|
+
});
|
|
7573
|
+
}
|
|
7574
|
+
else {
|
|
7575
|
+
e.features.forEach(function (el) {
|
|
7576
|
+
newFeatures.push({ type: el.type, geometry: el.geometry, properties: el.properties });
|
|
7577
|
+
});
|
|
7578
|
+
}
|
|
7579
|
+
});
|
|
7580
|
+
return newFeatures;
|
|
7581
|
+
}
|
|
7582
|
+
function convertTopojson(params) {
|
|
7583
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7584
|
+
var geojson;
|
|
7585
|
+
return __generator(this, function (_a) {
|
|
7586
|
+
switch (_a.label) {
|
|
7587
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve) {
|
|
7588
|
+
var topoJsonData = {
|
|
7589
|
+
type: 'Topology',
|
|
7590
|
+
objects: { key: '' },
|
|
7591
|
+
arcs: []
|
|
7592
|
+
};
|
|
7593
|
+
getProtocolData(params.filename).then(function (rawData) {
|
|
7594
|
+
try {
|
|
7595
|
+
topoJsonData = JSON.parse(rawData);
|
|
7596
|
+
}
|
|
7597
|
+
catch (e) {
|
|
7598
|
+
throw 'Invalid TopoJson';
|
|
7599
|
+
}
|
|
7600
|
+
// Convert the data
|
|
7601
|
+
var result = {
|
|
7602
|
+
type: 'FeatureCollection',
|
|
7603
|
+
features: [],
|
|
7604
|
+
};
|
|
7605
|
+
if (topoJsonData.type === 'Topology' && topoJsonData.objects !== undefined) {
|
|
7606
|
+
// add the "fromObject" property in each topojson feature
|
|
7607
|
+
Object.keys(topoJsonData.objects).map(function (key) {
|
|
7608
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7609
|
+
if (((_a = topoJsonData.objects) === null || _a === void 0 ? void 0 : _a[key].type) === 'GeometryCollection') {
|
|
7610
|
+
(_c = (_b = topoJsonData.objects) === null || _b === void 0 ? void 0 : _b[key].geometries) === null || _c === void 0 ? void 0 : _c.forEach(function (e) { return (e.properties = __assign({ fromObject: key }, e.properties)); });
|
|
7611
|
+
}
|
|
7612
|
+
else if (((_d = topoJsonData === null || topoJsonData === void 0 ? void 0 : topoJsonData.objects) === null || _d === void 0 ? void 0 : _d[key]) &&
|
|
7613
|
+
((_f = (_e = topoJsonData === null || topoJsonData === void 0 ? void 0 : topoJsonData.objects) === null || _e === void 0 ? void 0 : _e[key]) === null || _f === void 0 ? void 0 : _f.type) !== 'GeometryCollection') {
|
|
7614
|
+
topoJsonData.objects[key].properties = __assign({ fromObject: key }, (_g = topoJsonData.objects) === null || _g === void 0 ? void 0 : _g[key].properties);
|
|
7615
|
+
}
|
|
7616
|
+
});
|
|
7617
|
+
//convert the data into a geoJson object
|
|
7618
|
+
result = {
|
|
7619
|
+
type: 'FeatureCollection',
|
|
7620
|
+
features: Object.keys(topoJsonData.objects).map(function (key) {
|
|
7621
|
+
return topojsonClient.feature(topoJsonData, key);
|
|
7622
|
+
}),
|
|
7623
|
+
};
|
|
7624
|
+
result.features = reduceFeatures(result);
|
|
7625
|
+
}
|
|
7626
|
+
resolve(result);
|
|
7627
|
+
});
|
|
7628
|
+
})];
|
|
7629
|
+
case 1:
|
|
7630
|
+
geojson = _a.sent();
|
|
7631
|
+
return [2 /*return*/, geojson];
|
|
7632
|
+
}
|
|
7633
|
+
});
|
|
7634
|
+
});
|
|
7635
|
+
}
|
|
7636
|
+
var TopojsonProtocolHandler = function (params, callback) {
|
|
7637
|
+
var parsedParams = protocolPathParser(params.url);
|
|
7638
|
+
convertTopojson(parsedParams).then(function (data) {
|
|
7639
|
+
if (data !== undefined) {
|
|
7640
|
+
callback(null, data, null, null);
|
|
7641
|
+
}
|
|
7642
|
+
else {
|
|
7643
|
+
callback(new Error('Topojson not found'));
|
|
7644
|
+
}
|
|
7645
|
+
});
|
|
7646
|
+
return { cancel: function () { } };
|
|
7647
|
+
};
|
|
7648
|
+
|
|
7649
|
+
function convertOSM(params) {
|
|
7650
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7651
|
+
var options, geojson;
|
|
7652
|
+
return __generator(this, function (_a) {
|
|
7653
|
+
switch (_a.label) {
|
|
7654
|
+
case 0:
|
|
7655
|
+
options = params.options || {};
|
|
7656
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
7657
|
+
getProtocolData(params.filename).then(function (rawData) {
|
|
7658
|
+
var newData = osm2geojson__default["default"](rawData, options);
|
|
7659
|
+
if (!newData) {
|
|
7660
|
+
reject('Conversion failed');
|
|
7661
|
+
}
|
|
7662
|
+
else {
|
|
7663
|
+
resolve(newData);
|
|
7664
|
+
}
|
|
7665
|
+
});
|
|
7666
|
+
})];
|
|
7667
|
+
case 1:
|
|
7668
|
+
geojson = _a.sent();
|
|
7669
|
+
return [2 /*return*/, geojson];
|
|
7670
|
+
}
|
|
7671
|
+
});
|
|
7672
|
+
});
|
|
7673
|
+
}
|
|
7674
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7675
|
+
var OSMProtocolHandler = function (params, callback) {
|
|
7676
|
+
var parsedParams = protocolPathParser(params.url);
|
|
7677
|
+
convertOSM(parsedParams).then(function (data) {
|
|
7678
|
+
if (data !== undefined) {
|
|
7679
|
+
callback(null, data, null, null);
|
|
7680
|
+
}
|
|
7681
|
+
else {
|
|
7682
|
+
callback(new Error('OSM File not found'));
|
|
7683
|
+
}
|
|
7684
|
+
});
|
|
7685
|
+
return { cancel: function () { } };
|
|
7686
|
+
};
|
|
7687
|
+
|
|
7688
|
+
function convertXML(params) {
|
|
7689
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7690
|
+
var geojson;
|
|
7691
|
+
return __generator(this, function (_a) {
|
|
7692
|
+
switch (_a.label) {
|
|
7693
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
7694
|
+
getProtocolData(params.filename).then(function (rawData) {
|
|
7695
|
+
var newData = function () {
|
|
7696
|
+
// use an extern converter for tcx files
|
|
7697
|
+
if (params.protocolId === 'tcx') {
|
|
7698
|
+
return externParser__namespace[params.protocolId](new DOMParser().parseFromString(rawData, 'text/xml'));
|
|
7699
|
+
// use the projects gpxConverter function for gpx and kml files
|
|
7700
|
+
}
|
|
7701
|
+
else {
|
|
7702
|
+
return toGeoJSON[params.protocolId](new DOMParser().parseFromString(rawData, 'text/xml'));
|
|
7703
|
+
}
|
|
7704
|
+
};
|
|
7705
|
+
if (!newData()) {
|
|
7706
|
+
reject('Conversion failed');
|
|
7707
|
+
}
|
|
7708
|
+
else {
|
|
7709
|
+
resolve(newData());
|
|
7710
|
+
}
|
|
7711
|
+
});
|
|
7712
|
+
})];
|
|
7713
|
+
case 1:
|
|
7714
|
+
geojson = _a.sent();
|
|
7715
|
+
return [2 /*return*/, geojson];
|
|
7716
|
+
}
|
|
7717
|
+
});
|
|
7718
|
+
});
|
|
7719
|
+
}
|
|
7720
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7721
|
+
var XMLProtocolHandler = function (params, callback) {
|
|
7722
|
+
var parsedParams = protocolPathParser(params.url);
|
|
7723
|
+
convertXML(parsedParams).then(function (data) {
|
|
7724
|
+
if (data !== undefined) {
|
|
7725
|
+
callback(null, data, null, null);
|
|
7726
|
+
}
|
|
7727
|
+
else {
|
|
7728
|
+
callback(new Error('XML not found'));
|
|
7729
|
+
}
|
|
7730
|
+
});
|
|
7731
|
+
return { cancel: function () { } };
|
|
7732
|
+
};
|
|
7733
|
+
|
|
7734
|
+
var loadedMbtiles = {};
|
|
7735
|
+
var parseTileParams = function (url) {
|
|
7736
|
+
var urlParts = url.split('://');
|
|
7737
|
+
var mbtilesUrl = urlParts.length > 2 ? urlParts[1] + '://' + urlParts[2] : urlParts[1];
|
|
7738
|
+
var mbtilesParts = mbtilesUrl.split('/');
|
|
7739
|
+
var mbtilesPartsLength = mbtilesParts.length;
|
|
7740
|
+
var y = mbtilesParts.splice(mbtilesPartsLength - 1, 1)[0];
|
|
7741
|
+
var x = mbtilesParts.splice(mbtilesPartsLength - 2, 1)[0];
|
|
7742
|
+
var z = mbtilesParts.splice(mbtilesPartsLength - 3, 1)[0];
|
|
7743
|
+
var filename = mbtilesParts.join('/');
|
|
7744
|
+
return {
|
|
7745
|
+
filename: filename,
|
|
7746
|
+
z: z,
|
|
7747
|
+
x: x,
|
|
7748
|
+
y: y,
|
|
7749
|
+
};
|
|
7750
|
+
};
|
|
7751
|
+
// mbtiles files are sqlite databases. This function loads the database and returns a handler
|
|
7752
|
+
// to work with sqlite databases in javascript we need to use sql.js.
|
|
7753
|
+
// to make this work in your project make sure to copy sql-wasm.wasm to the file root of your public folder and
|
|
7754
|
+
// add the following config to the externals prop of your webpack config
|
|
7755
|
+
// {externals: { fs: 'fs' }};
|
|
7756
|
+
var getMbtilesDbHandler = function (_a) {
|
|
7757
|
+
var filename = _a.filename;
|
|
7758
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
7759
|
+
var SQL, fetched, buf, db;
|
|
7760
|
+
return __generator(this, function (_b) {
|
|
7761
|
+
switch (_b.label) {
|
|
7762
|
+
case 0:
|
|
7763
|
+
if (!!loadedMbtiles[filename]) return [3 /*break*/, 4];
|
|
7764
|
+
return [4 /*yield*/, initSqlJs__default["default"]()];
|
|
7765
|
+
case 1:
|
|
7766
|
+
SQL = _b.sent();
|
|
7767
|
+
return [4 /*yield*/, fetch(filename)];
|
|
7768
|
+
case 2:
|
|
7769
|
+
fetched = _b.sent();
|
|
7770
|
+
return [4 /*yield*/, fetched.arrayBuffer()];
|
|
7771
|
+
case 3:
|
|
7772
|
+
buf = _b.sent();
|
|
7773
|
+
db = new SQL.Database(new Uint8Array(buf));
|
|
7774
|
+
loadedMbtiles[filename] = db;
|
|
7775
|
+
_b.label = 4;
|
|
7776
|
+
case 4: return [2 /*return*/, loadedMbtiles[filename]];
|
|
7777
|
+
}
|
|
7778
|
+
});
|
|
7779
|
+
});
|
|
7780
|
+
};
|
|
7781
|
+
/**
|
|
7782
|
+
* Example usage:
|
|
7783
|
+
* getBufferFromMbtiles({ filename: 'mbtiles/countries.mbtiles', z: '0', x: '0', y: '0' }).then(
|
|
7784
|
+
* (result) => {
|
|
7785
|
+
* console.log(result);
|
|
7786
|
+
* }
|
|
7787
|
+
* );
|
|
7788
|
+
*/
|
|
7789
|
+
function getBufferFromMbtiles(params) {
|
|
7790
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7791
|
+
var db, query;
|
|
7792
|
+
return __generator(this, function (_a) {
|
|
7793
|
+
switch (_a.label) {
|
|
7794
|
+
case 0: return [4 /*yield*/, getMbtilesDbHandler(params)];
|
|
7795
|
+
case 1:
|
|
7796
|
+
db = _a.sent();
|
|
7797
|
+
query = 'SELECT tile_data FROM tiles WHERE zoom_level = ' +
|
|
7798
|
+
params.z +
|
|
7799
|
+
' AND tile_column = ' +
|
|
7800
|
+
params.x +
|
|
7801
|
+
' AND tile_row = ' +
|
|
7802
|
+
(Math.pow(2, parseInt(params.z)) - parseInt(params.y) - 1);
|
|
7803
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
7804
|
+
try {
|
|
7805
|
+
// some of the logic here was heavily inspired by
|
|
7806
|
+
// https://github.com/IsraelHikingMap/Site/blob/6aa2ec0cfb8891fa048b1d9e2a4fc7d4cbcc8c97/IsraelHiking.Web/src/application/services/database.service.ts
|
|
7807
|
+
var result = db.exec(query);
|
|
7808
|
+
if (result.length !== 1) {
|
|
7809
|
+
reject(new Error('Tile not found.'));
|
|
7810
|
+
return;
|
|
7811
|
+
}
|
|
7812
|
+
var resultData = result[0].values[0][0];
|
|
7813
|
+
var binData = void 0;
|
|
7814
|
+
var isGzipped = resultData[0] === 0x1f && resultData[1] === 0x8b;
|
|
7815
|
+
if (isGzipped) {
|
|
7816
|
+
binData = pako__namespace.inflate(resultData);
|
|
7817
|
+
}
|
|
7818
|
+
else {
|
|
7819
|
+
binData = resultData;
|
|
7820
|
+
}
|
|
7821
|
+
if (binData === null || binData === void 0 ? void 0 : binData.buffer) {
|
|
7822
|
+
resolve(binData.buffer);
|
|
7823
|
+
}
|
|
7824
|
+
else {
|
|
7825
|
+
reject(new Error('Tile not found.'));
|
|
7826
|
+
return;
|
|
7827
|
+
}
|
|
7828
|
+
}
|
|
7829
|
+
catch (error) {
|
|
7830
|
+
reject(error);
|
|
7831
|
+
}
|
|
7832
|
+
})];
|
|
7833
|
+
}
|
|
7834
|
+
});
|
|
7835
|
+
});
|
|
7836
|
+
}
|
|
7837
|
+
/**
|
|
7838
|
+
* Expects a tile url in the following format:
|
|
7839
|
+
*
|
|
7840
|
+
* 'mbtiles://mbtiles/countries.mbtiles/{z}/{x}/{y}'
|
|
7841
|
+
*/
|
|
7842
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7843
|
+
var mbTilesProtocolHandler = function (params, callback) {
|
|
7844
|
+
var parsedParams = parseTileParams(params.url);
|
|
7845
|
+
getBufferFromMbtiles(parsedParams).then(function (result) {
|
|
7846
|
+
if (result) {
|
|
7847
|
+
callback(null, result, null, null);
|
|
7848
|
+
}
|
|
7849
|
+
else {
|
|
7850
|
+
callback(new Error('Tile not found'));
|
|
7851
|
+
}
|
|
7852
|
+
});
|
|
7853
|
+
return { cancel: function () { } };
|
|
7854
|
+
};
|
|
7855
|
+
|
|
7856
|
+
var handlers = {
|
|
7857
|
+
csv: CSVProtocolHandler,
|
|
7858
|
+
topojson: TopojsonProtocolHandler,
|
|
7859
|
+
osm: OSMProtocolHandler,
|
|
7860
|
+
gpx: XMLProtocolHandler,
|
|
7861
|
+
kml: XMLProtocolHandler,
|
|
7862
|
+
tcx: XMLProtocolHandler,
|
|
7863
|
+
mbtiles: mbTilesProtocolHandler
|
|
7864
|
+
};
|
|
7865
|
+
var types = ['fill', 'line', 'circle'];
|
|
7866
|
+
function ProtocolHandlerLayerForm(props) {
|
|
7867
|
+
var _a = React.useState({ type: 'circle' }), config = _a[0], setConfig = _a[1];
|
|
7868
|
+
var _b = React.useState(), fileName = _b[0], setFileName = _b[1];
|
|
7869
|
+
var _c = React.useState(), filePath = _c[0], setFilePath = _c[1];
|
|
7870
|
+
var _d = React.useState({}), optionsObject = _d[0], setOptionsObject = _d[1];
|
|
7871
|
+
var mapHook = useMap({ mapId: props.mapId });
|
|
7872
|
+
var optionsURL = '?' + new URLSearchParams(optionsObject).toString();
|
|
7873
|
+
useAddProtocol({
|
|
7874
|
+
protocol: props.originType,
|
|
7875
|
+
handler: handlers[props.originType],
|
|
7876
|
+
});
|
|
7877
|
+
var configIsValid = React.useMemo(function () {
|
|
7878
|
+
if (!(config === null || config === void 0 ? void 0 : config.type))
|
|
7879
|
+
return false;
|
|
7880
|
+
if (filePath && fileName)
|
|
7881
|
+
return true;
|
|
7882
|
+
else
|
|
7883
|
+
return false;
|
|
7884
|
+
}, [config, filePath, fileName]);
|
|
7885
|
+
React.useEffect(function () {
|
|
7886
|
+
var _a, _b;
|
|
7887
|
+
if (typeof fileName !== 'undefined' && typeof filePath !== 'undefined') {
|
|
7888
|
+
if (!((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.getSource(fileName)))
|
|
7889
|
+
(_b = mapHook.map) === null || _b === void 0 ? void 0 : _b.addSource(fileName, {
|
|
7890
|
+
type: 'geojson',
|
|
7891
|
+
data: optionsObject ? props.originType + '://' + filePath + optionsURL : props.originType + '://' + filePath,
|
|
7892
|
+
});
|
|
7893
|
+
config.options = { source: fileName };
|
|
7894
|
+
}
|
|
7895
|
+
return function () { };
|
|
7896
|
+
}, [fileName, mapHook.map, filePath]);
|
|
7897
|
+
//the temporally storage adress of the uploaded file will be revoked, after source and layer are loaded in the map
|
|
7898
|
+
React.useEffect(function () {
|
|
7899
|
+
var _a;
|
|
7900
|
+
if (filePath && fileName && ((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.getLayer(fileName))) {
|
|
7901
|
+
URL.revokeObjectURL(filePath);
|
|
7902
|
+
}
|
|
7903
|
+
}, [fileName, filePath, mapHook.map]);
|
|
7904
|
+
function addOption(newObject) {
|
|
7905
|
+
var newOptions = __assign(__assign({}, optionsObject), newObject);
|
|
7906
|
+
return setOptionsObject(newOptions);
|
|
7907
|
+
}
|
|
7908
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7909
|
+
React__default["default"].createElement(material.DialogTitle, null,
|
|
7910
|
+
"Layer from ",
|
|
7911
|
+
props.originType),
|
|
7912
|
+
React__default["default"].createElement(material.FormControl, { fullWidth: true },
|
|
7913
|
+
React__default["default"].createElement(material.InputLabel, { id: "type-label" }, "Type"),
|
|
7914
|
+
React__default["default"].createElement(material.Select, { labelId: "type-label", value: config.type, label: "Type", onChange: function (ev) {
|
|
7915
|
+
return setConfig(function (current) { return (__assign(__assign({}, current), { type: ev.target.value })); });
|
|
7916
|
+
} }, types.map(function (type) { return (React__default["default"].createElement(material.MenuItem, { key: type, value: type }, type)); }))),
|
|
7917
|
+
React__default["default"].createElement(material.FormControl, { fullWidth: true },
|
|
7918
|
+
React__default["default"].createElement(material.Button, { variant: "contained", component: "label", sx: { marginTop: '10px' } },
|
|
7919
|
+
"Select origin file",
|
|
7920
|
+
React__default["default"].createElement("input", { type: "file", hidden: true, accept: props.originType, onChange: function (ev) {
|
|
7921
|
+
var _a, _b, _c;
|
|
7922
|
+
setFileName((_a = ev.target.files) === null || _a === void 0 ? void 0 : _a[0].name);
|
|
7923
|
+
if ((_b = ev.target.files) === null || _b === void 0 ? void 0 : _b[0]) {
|
|
7924
|
+
var dataUrl = URL.createObjectURL((_c = ev.target.files) === null || _c === void 0 ? void 0 : _c[0]);
|
|
7925
|
+
setFilePath(dataUrl);
|
|
7926
|
+
}
|
|
7927
|
+
} })),
|
|
7928
|
+
props.originType === 'csv' && React__default["default"].createElement(CSVOptionsFormular, { setter: addOption }),
|
|
7929
|
+
props.originType === 'osm' && React__default["default"].createElement(OsmOptionsFomular, { setter: addOption })),
|
|
7930
|
+
React__default["default"].createElement(material.DialogActions, null,
|
|
7931
|
+
React__default["default"].createElement(material.Button, { onClick: props.onCancel }, "Cancel"),
|
|
7932
|
+
React__default["default"].createElement(material.Button, { disabled: !configIsValid, onClick: function () { return props.onSubmit(config); } }, "Add"))));
|
|
7933
|
+
}
|
|
7934
|
+
|
|
7935
|
+
var LayerSpecificationKeys = [
|
|
7936
|
+
'id',
|
|
7937
|
+
'type',
|
|
7938
|
+
'metadata',
|
|
7939
|
+
'source',
|
|
7940
|
+
'source-layer',
|
|
7941
|
+
'layout',
|
|
7942
|
+
'paint',
|
|
7943
|
+
'options',
|
|
7944
|
+
];
|
|
7945
|
+
function MbtilesLayerPropFormular(props) {
|
|
7946
|
+
var _a = React.useState([]), layers = _a[0], setLayers = _a[1];
|
|
7947
|
+
var newLayer = {};
|
|
7948
|
+
var toJSON = ['paint', 'layout', 'options', 'metadata'];
|
|
7949
|
+
React.useEffect(function () {
|
|
7950
|
+
props.setter(layers);
|
|
7951
|
+
}, [layers]);
|
|
7952
|
+
var TextFields = function () {
|
|
7953
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, LayerSpecificationKeys.map(function (key) {
|
|
7954
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, { key: key + '_fragment' },
|
|
7955
|
+
React__default["default"].createElement(material.TextField, { label: key, onChange: function (ev) {
|
|
7956
|
+
return newLayer[key] = ev.target.value;
|
|
7957
|
+
} })));
|
|
7958
|
+
})));
|
|
7959
|
+
};
|
|
7960
|
+
function addLayer() {
|
|
7961
|
+
toJSON.map(function (key) {
|
|
7962
|
+
if (typeof newLayer[key] !== 'undefined') {
|
|
7963
|
+
try {
|
|
7964
|
+
newLayer[key] = JSON.parse(newLayer[key]);
|
|
7965
|
+
}
|
|
7966
|
+
catch (_a) {
|
|
7967
|
+
alert("Invalid JSON format, try again");
|
|
7968
|
+
}
|
|
7969
|
+
}
|
|
7970
|
+
});
|
|
7971
|
+
setLayers(function (current) {
|
|
7972
|
+
if (current.length > 0) {
|
|
7973
|
+
return __spreadArray([newLayer], current, true);
|
|
7974
|
+
}
|
|
7975
|
+
else {
|
|
7976
|
+
return [newLayer];
|
|
7977
|
+
}
|
|
7978
|
+
});
|
|
7979
|
+
}
|
|
7980
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7981
|
+
React__default["default"].createElement(material.FormControl, { fullWidth: true },
|
|
7982
|
+
React__default["default"].createElement(TextFields, null)),
|
|
7983
|
+
React__default["default"].createElement(material.Button, { onClick: addLayer }, " Add")));
|
|
7984
|
+
}
|
|
7985
|
+
|
|
7986
|
+
function MbtilesLayerForm(props) {
|
|
7987
|
+
var _a = React__default["default"].useState(props.config), config = _a[0], setConfig = _a[1];
|
|
7988
|
+
var _b = React.useState(), fileName = _b[0], setFileName = _b[1];
|
|
7989
|
+
var _c = React.useState(), filePath = _c[0], setFilePath = _c[1];
|
|
7990
|
+
var _d = React.useState([]), layers = _d[0], setLayers = _d[1];
|
|
7991
|
+
var mapHook = useMap({ mapId: props.mapId });
|
|
7992
|
+
var _e = React.useState(false), expanded = _e[0], setExpanded = _e[1];
|
|
7993
|
+
console.log(layers);
|
|
7994
|
+
var LayersToCall = function () {
|
|
7995
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, layers.map(function (el, idx) { return (React__default["default"].createElement(material.Typography, { variant: "body2", key: idx },
|
|
7996
|
+
idx + 1,
|
|
7997
|
+
": ",
|
|
7998
|
+
JSON.stringify(el))); })));
|
|
7999
|
+
};
|
|
8000
|
+
/**
|
|
8001
|
+
* A Vector Tile layer configuration with a mbtile Protocol url will passed to the onComplete function of the addLayerButton.
|
|
8002
|
+
* In order to visdualize the file content, a mbtiles ProtocolHandler must be added to the map Instanz.
|
|
8003
|
+
* See the MapComponents AddLayerButton demo and the documentation of useAddProtocolHook to find out more about Protocol handlers.
|
|
8004
|
+
*/
|
|
8005
|
+
/* example values:
|
|
8006
|
+
* id: 'countries',
|
|
8007
|
+
* type: 'fill',
|
|
8008
|
+
* 'source-layer': 'countries',
|
|
8009
|
+
* layout: {},
|
|
8010
|
+
* paint: { "fill-color": "#f9a5f5", "fill-opacity": 0.5 },
|
|
8011
|
+
*/
|
|
8012
|
+
var configIsValid = React.useMemo(function () {
|
|
8013
|
+
if (!fileName)
|
|
8014
|
+
return false;
|
|
8015
|
+
return true;
|
|
8016
|
+
}, [fileName]);
|
|
8017
|
+
React.useEffect(function () {
|
|
8018
|
+
if (typeof fileName !== 'undefined' && typeof filePath !== 'undefined') {
|
|
8019
|
+
setConfig({
|
|
8020
|
+
url: 'mbtiles://' + filePath + '/{z}/{x}/{y}',
|
|
8021
|
+
layers: layers,
|
|
8022
|
+
layerId: fileName,
|
|
8023
|
+
sourceOptions: {
|
|
8024
|
+
type: 'vector',
|
|
8025
|
+
minzoom: 0,
|
|
8026
|
+
maxzoom: 1,
|
|
8027
|
+
},
|
|
8028
|
+
});
|
|
8029
|
+
}
|
|
8030
|
+
}, [fileName, mapHook.map, filePath, layers]);
|
|
8031
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
8032
|
+
React__default["default"].createElement(material.DialogTitle, null, " Layer from mbtiles file"),
|
|
8033
|
+
React__default["default"].createElement(material.DialogContent, null,
|
|
8034
|
+
React__default["default"].createElement(material.Button, { variant: "contained", component: "label", sx: { marginTop: '10px' } },
|
|
8035
|
+
"Select origin file",
|
|
8036
|
+
React__default["default"].createElement("input", { type: "file", hidden: true, accept: props.originType, onChange: function (ev) {
|
|
8037
|
+
var _a, _b, _c;
|
|
8038
|
+
setFileName((_a = ev.target.files) === null || _a === void 0 ? void 0 : _a[0].name);
|
|
8039
|
+
if ((_b = ev.target.files) === null || _b === void 0 ? void 0 : _b[0]) {
|
|
8040
|
+
var dataUrl = URL.createObjectURL((_c = ev.target.files) === null || _c === void 0 ? void 0 : _c[0]);
|
|
8041
|
+
setFilePath(dataUrl);
|
|
8042
|
+
}
|
|
8043
|
+
} })),
|
|
8044
|
+
React__default["default"].createElement(material.Accordion, { expanded: expanded },
|
|
8045
|
+
React__default["default"].createElement(material.AccordionSummary, { "aria-controls": "panel1d-content", id: "panel1d-header" },
|
|
8046
|
+
React__default["default"].createElement(material.Typography, null, "MB-Tile Layer properties"),
|
|
8047
|
+
React__default["default"].createElement(material.Button, { onClick: function () { return setExpanded(!expanded); } }, expanded ? React__default["default"].createElement(KeyboardArrowUpIcon__default["default"], null) : React__default["default"].createElement(KeyboardArrowDownIcon__default["default"], null))),
|
|
8048
|
+
React__default["default"].createElement(material.Typography, { variant: "body1" }, " Layers"),
|
|
8049
|
+
layers.length > 0 ? React__default["default"].createElement(LayersToCall, null) : React__default["default"].createElement(material.Typography, { variant: "body2" }, " 0 "),
|
|
8050
|
+
React__default["default"].createElement(MbtilesLayerPropFormular, { setter: setLayers }))),
|
|
8051
|
+
React__default["default"].createElement(material.DialogActions, null,
|
|
8052
|
+
React__default["default"].createElement(material.Button, { onClick: props.onCancel }, "Cancel"),
|
|
8053
|
+
React__default["default"].createElement(material.Button, { disabled: !configIsValid, onClick: function () { return props.onSubmit(config); } }, "Add"))));
|
|
8054
|
+
}
|
|
8055
|
+
|
|
7115
8056
|
var AddLayerPopup = function (props) {
|
|
7116
8057
|
var _a = React.useState(props === null || props === void 0 ? void 0 : props.config), layerConfig = _a[0], setLayerConfig = _a[1];
|
|
8058
|
+
var _b = React.useState(), originType = _b[0], setOriginType = _b[1];
|
|
8059
|
+
var layerTypes = props.layerTypes;
|
|
8060
|
+
var supportedProtocols = layerTypes.filter(function (el) { return el !== 'wms' && el !== 'geojson' && el !== 'mbtiles'; });
|
|
7117
8061
|
var updateLayerType = function (type) {
|
|
7118
|
-
|
|
8062
|
+
setOriginType(type);
|
|
8063
|
+
if (supportedProtocols.includes(type)) {
|
|
8064
|
+
setLayerConfig({ type: 'geojson', config: {} });
|
|
8065
|
+
}
|
|
8066
|
+
else if (type === 'mbtiles') {
|
|
8067
|
+
setLayerConfig({ type: 'vt', config: { layers: [] } });
|
|
8068
|
+
}
|
|
8069
|
+
else {
|
|
8070
|
+
setLayerConfig({ type: type, config: {} });
|
|
8071
|
+
}
|
|
7119
8072
|
};
|
|
7120
8073
|
var handleCancel = function () {
|
|
7121
8074
|
props.setOpen(false);
|
|
7122
8075
|
setLayerConfig(undefined);
|
|
7123
8076
|
};
|
|
8077
|
+
var ProtocolTypeFormulars = function () {
|
|
8078
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, supportedProtocols.map(function (el, idx) {
|
|
8079
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, (layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) === 'geojson' && originType === el && (React__default["default"].createElement(ProtocolHandlerLayerForm, { key: idx, originType: el, onSubmit: function (config) {
|
|
8080
|
+
var _a;
|
|
8081
|
+
(_a = props === null || props === void 0 ? void 0 : props.onComplete) === null || _a === void 0 ? void 0 : _a.call(props, __assign(__assign({}, layerConfig), { config: config, type: 'geojson' }));
|
|
8082
|
+
handleCancel();
|
|
8083
|
+
}, onCancel: handleCancel }))));
|
|
8084
|
+
})));
|
|
8085
|
+
};
|
|
7124
8086
|
return (React__default["default"].createElement(material.Dialog, { open: props.open, onClose: handleCancel, PaperProps: { sx: { padding: '20px' } } },
|
|
7125
|
-
!(layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) && React__default["default"].createElement(LayerTypeForm, { onSelect: updateLayerType }),
|
|
7126
|
-
(layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) === 'geojson' && (React__default["default"].createElement(GeoJsonLayerForm, { onSubmit: function (config) {
|
|
8087
|
+
!(layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) && React__default["default"].createElement(LayerTypeForm, { onSelect: updateLayerType, layerTypes: layerTypes }),
|
|
8088
|
+
(layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) === 'geojson' && originType === 'geojson' && (React__default["default"].createElement(GeoJsonLayerForm, { onSubmit: function (config) {
|
|
7127
8089
|
var _a;
|
|
7128
8090
|
(_a = props === null || props === void 0 ? void 0 : props.onComplete) === null || _a === void 0 ? void 0 : _a.call(props, __assign(__assign({}, layerConfig), { config: config }));
|
|
7129
8091
|
handleCancel();
|
|
@@ -7132,16 +8094,29 @@ var AddLayerPopup = function (props) {
|
|
|
7132
8094
|
var _a;
|
|
7133
8095
|
(_a = props === null || props === void 0 ? void 0 : props.onComplete) === null || _a === void 0 ? void 0 : _a.call(props, __assign(__assign({}, layerConfig), { config: config }));
|
|
7134
8096
|
handleCancel();
|
|
7135
|
-
}, onCancel: handleCancel }))
|
|
8097
|
+
}, onCancel: handleCancel })),
|
|
8098
|
+
(layerConfig === null || layerConfig === void 0 ? void 0 : layerConfig.type) === 'vt' && originType !== undefined && (React__default["default"].createElement(MbtilesLayerForm, { config: layerConfig, originType: originType, onSubmit: function (config) {
|
|
8099
|
+
var _a;
|
|
8100
|
+
if (layerConfig) {
|
|
8101
|
+
(_a = props === null || props === void 0 ? void 0 : props.onComplete) === null || _a === void 0 ? void 0 : _a.call(props, __assign(__assign({}, layerConfig), { config: config }));
|
|
8102
|
+
handleCancel();
|
|
8103
|
+
}
|
|
8104
|
+
}, onCancel: handleCancel })),
|
|
8105
|
+
React__default["default"].createElement(ProtocolTypeFormulars, { key: 'protocol' })));
|
|
7136
8106
|
};
|
|
7137
8107
|
AddLayerPopup.defaultProps = {};
|
|
7138
8108
|
|
|
7139
8109
|
var AddLayerButton = function (props) {
|
|
7140
8110
|
var _a = React__default["default"].useState(false), popupOpen = _a[0], setPopupOpen = _a[1];
|
|
8111
|
+
var layerTypes = props.layerTypes || ['geojson', 'wms', 'mbtiles', 'csv', 'topojson', 'osm', 'gpx', 'kml', 'tcx'];
|
|
8112
|
+
layerTypes.includes('mbtiles') && useAddProtocol({
|
|
8113
|
+
protocol: 'mbtiles',
|
|
8114
|
+
handler: mbTilesProtocolHandler,
|
|
8115
|
+
});
|
|
7141
8116
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7142
8117
|
React__default["default"].createElement(material.Button, { variant: "contained", sx: __assign({ marginTop: '10px' }, props.sx), onClick: function () { return setPopupOpen(true); } },
|
|
7143
8118
|
React__default["default"].createElement(PlaylistAddIcon__default["default"], null)),
|
|
7144
|
-
React__default["default"].createElement(AddLayerPopup, { open: popupOpen, setOpen: setPopupOpen, onComplete: props === null || props === void 0 ? void 0 : props.onComplete })));
|
|
8119
|
+
React__default["default"].createElement(AddLayerPopup, { open: popupOpen, setOpen: setPopupOpen, onComplete: props === null || props === void 0 ? void 0 : props.onComplete, layerTypes: layerTypes })));
|
|
7145
8120
|
};
|
|
7146
8121
|
AddLayerButton.defaultProps = {};
|
|
7147
8122
|
|
|
@@ -7162,7 +8137,8 @@ function TopToolbar(props) {
|
|
|
7162
8137
|
minHeight: '62px',
|
|
7163
8138
|
position: 'absolute',
|
|
7164
8139
|
zIndex: 1300,
|
|
7165
|
-
|
|
8140
|
+
top: 0,
|
|
8141
|
+
} },
|
|
7166
8142
|
React__namespace.createElement(Toolbar__default["default"], { disableGutters: true },
|
|
7167
8143
|
props.logo || (React__namespace.createElement(React__namespace.Fragment, null,
|
|
7168
8144
|
React__namespace.createElement(Box__default["default"], { sx: {
|
|
@@ -20214,6 +21190,7 @@ exports.MlOsmLayer = MlOsmLayer;
|
|
|
20214
21190
|
exports.MlPdfPreview = PdfPreview;
|
|
20215
21191
|
exports.MlScaleReference = MlScaleReference;
|
|
20216
21192
|
exports.MlShareMapState = MlShareMapState;
|
|
21193
|
+
exports.MlSketchTool = MlSketchTool;
|
|
20217
21194
|
exports.MlSpatialElevationProfile = MlSpatialElevationProfile;
|
|
20218
21195
|
exports.MlTemporalController = MlTemporalController;
|
|
20219
21196
|
exports.MlTerrainLayer = MlTerrainLayer;
|