@mapcomponents/react-maplibre 1.2.0 → 1.3.0
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 +6 -0
- package/dist/index.cjs.js +236 -110
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +237 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/MlComponentTemplate/MlComponentTemplate.stories_.d.ts +14 -0
- package/dist/src/components/MlMarker/MlMarker.d.ts +21 -26
- package/dist/src/hooks/useFeatureEditor/utils/FeatureEditorStyle.d.ts +28 -0
- package/package.json +29 -29
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -41,7 +41,6 @@ var ControlPointIcon = require('@mui/icons-material/ControlPoint');
|
|
|
41
41
|
var RemoveCircleOutlineIcon = require('@mui/icons-material/RemoveCircleOutline');
|
|
42
42
|
var Divider = require('@mui/material/Divider');
|
|
43
43
|
var syncMove = require('@mapbox/mapbox-gl-sync-move');
|
|
44
|
-
var Paper = require('@mui/material/Paper');
|
|
45
44
|
var xmldom = require('@xmldom/xmldom');
|
|
46
45
|
var helpers = require('@turf/helpers');
|
|
47
46
|
var WMSCapabilities = require('wms-capabilities');
|
|
@@ -2093,7 +2092,8 @@ function featureEditorStyle() {
|
|
|
2093
2092
|
},
|
|
2094
2093
|
paint: {
|
|
2095
2094
|
'line-color': '#009EE0',
|
|
2096
|
-
'line-width':
|
|
2095
|
+
'line-width': 10,
|
|
2096
|
+
'line-opacity': 0.2,
|
|
2097
2097
|
},
|
|
2098
2098
|
},
|
|
2099
2099
|
{
|
|
@@ -2105,7 +2105,7 @@ function featureEditorStyle() {
|
|
|
2105
2105
|
'line-join': 'round',
|
|
2106
2106
|
},
|
|
2107
2107
|
paint: {
|
|
2108
|
-
'line-color':
|
|
2108
|
+
'line-color': '#009EE0',
|
|
2109
2109
|
'line-dasharray': [0.2, 2],
|
|
2110
2110
|
'line-width': 2,
|
|
2111
2111
|
},
|
|
@@ -2118,7 +2118,7 @@ function featureEditorStyle() {
|
|
|
2118
2118
|
'circle-radius': mediaIsMobile ? 5 : 4,
|
|
2119
2119
|
'circle-color': '#ffffff',
|
|
2120
2120
|
'circle-stroke-color': '#009EE0',
|
|
2121
|
-
'circle-stroke-width': 1
|
|
2121
|
+
'circle-stroke-width': 1,
|
|
2122
2122
|
},
|
|
2123
2123
|
},
|
|
2124
2124
|
{
|
|
@@ -2138,7 +2138,7 @@ function featureEditorStyle() {
|
|
|
2138
2138
|
'circle-radius': mediaIsMobile ? 7 : 5,
|
|
2139
2139
|
'circle-color': '#ffffff',
|
|
2140
2140
|
'circle-stroke-color': '#009EE0',
|
|
2141
|
-
'circle-stroke-width': 1
|
|
2141
|
+
'circle-stroke-width': 1,
|
|
2142
2142
|
},
|
|
2143
2143
|
},
|
|
2144
2144
|
{
|
|
@@ -2655,15 +2655,21 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
2655
2655
|
return defaultPaintOverrides.fill;
|
|
2656
2656
|
}
|
|
2657
2657
|
return {
|
|
2658
|
-
'fill-color': 'rgba(10,240,256,0.6)',
|
|
2659
|
-
'fill-outline-color': 'rgba(20,230,256,0.8)',
|
|
2658
|
+
// 'fill-color': 'rgba(10,240,256,0.6)',
|
|
2659
|
+
// 'fill-outline-color': 'rgba(20,230,256,0.8)',
|
|
2660
|
+
'fill-color': '#009EE0',
|
|
2661
|
+
'fill-outline-color': '#009EE0',
|
|
2660
2662
|
};
|
|
2661
2663
|
case 'line':
|
|
2662
2664
|
if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
|
|
2665
|
+
console.log(defaultPaintOverrides.line);
|
|
2663
2666
|
return defaultPaintOverrides.line;
|
|
2664
2667
|
}
|
|
2665
2668
|
return {
|
|
2666
|
-
'line-color': 'rgb(203,211,2)',
|
|
2669
|
+
// // 'line-color': 'rgb(203,211,2)',
|
|
2670
|
+
// 'line-width': 5,
|
|
2671
|
+
// 'line-blur': 0,
|
|
2672
|
+
'line-color': '#009EE0',
|
|
2667
2673
|
'line-width': 5,
|
|
2668
2674
|
'line-blur': 0,
|
|
2669
2675
|
};
|
|
@@ -2672,10 +2678,14 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
2672
2678
|
return defaultPaintOverrides.circle;
|
|
2673
2679
|
}
|
|
2674
2680
|
return {
|
|
2675
|
-
'circle-color': 'rgba(10,240,256,0.8)',
|
|
2681
|
+
// 'circle-color': 'rgba(10,240,256,0.8)',
|
|
2682
|
+
// 'circle-stroke-color': '#fff',
|
|
2683
|
+
// 'circle-stroke-width': 2,
|
|
2684
|
+
// 'circle-radius': 4,
|
|
2685
|
+
'circle-color': '#009EE0',
|
|
2676
2686
|
'circle-stroke-color': '#fff',
|
|
2677
2687
|
'circle-stroke-width': 2,
|
|
2678
|
-
'circle-radius':
|
|
2688
|
+
'circle-radius': 5,
|
|
2679
2689
|
};
|
|
2680
2690
|
default:
|
|
2681
2691
|
return {};
|
|
@@ -4604,76 +4614,130 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4604
4614
|
React.createElement(MlGeoJsonLayer, __assign({}, restProps, { geojson: displayGeojson }))));
|
|
4605
4615
|
};
|
|
4606
4616
|
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4617
|
+
var getBoxTransform = function (anchor) {
|
|
4618
|
+
if (anchor === void 0) { anchor = 'top'; }
|
|
4619
|
+
switch (anchor) {
|
|
4620
|
+
case 'bottom':
|
|
4621
|
+
return 'translate(-50%, 0%)';
|
|
4622
|
+
case 'left':
|
|
4623
|
+
return 'translate(-100%, -50%)';
|
|
4624
|
+
case 'right':
|
|
4625
|
+
return 'translate(0%, -50%)';
|
|
4626
|
+
case 'top-left':
|
|
4627
|
+
return 'translate(-100%, -100%)';
|
|
4628
|
+
case 'top-right':
|
|
4629
|
+
return 'translate(0%, -100%)';
|
|
4630
|
+
case 'bottom-left':
|
|
4631
|
+
return 'translate(-100%, 0%)';
|
|
4632
|
+
case 'bottom-right':
|
|
4633
|
+
return 'translate(0%, 0%)';
|
|
4634
|
+
default:
|
|
4635
|
+
case 'top':
|
|
4636
|
+
return 'translate(-50%, -100%)';
|
|
4637
|
+
}
|
|
4638
|
+
};
|
|
4639
|
+
function getBoxMargins(anchor, offset, style) {
|
|
4640
|
+
var w = parseInt(String((style === null || style === void 0 ? void 0 : style.width) || 14), 10);
|
|
4641
|
+
var h = parseInt(String((style === null || style === void 0 ? void 0 : style.height) || 14), 10);
|
|
4642
|
+
var m = {};
|
|
4643
|
+
switch (anchor) {
|
|
4644
|
+
case 'bottom':
|
|
4645
|
+
m.marginTop = "".concat(offset, "px");
|
|
4646
|
+
break;
|
|
4647
|
+
case 'left':
|
|
4648
|
+
m.marginLeft = "-".concat(offset, "px");
|
|
4649
|
+
break;
|
|
4650
|
+
case 'right':
|
|
4651
|
+
m.marginLeft = "".concat(w + offset, "px");
|
|
4652
|
+
break;
|
|
4653
|
+
case 'top-left':
|
|
4654
|
+
m.marginTop = "-".concat(h + offset, "px");
|
|
4655
|
+
m.marginLeft = "-".concat(offset, "px");
|
|
4656
|
+
break;
|
|
4657
|
+
case 'top-right':
|
|
4658
|
+
m.marginTop = "-".concat(h + offset, "px");
|
|
4659
|
+
m.marginLeft = "".concat(w + offset, "px");
|
|
4660
|
+
break;
|
|
4661
|
+
case 'bottom-left':
|
|
4662
|
+
m.marginTop = "".concat(offset, "px");
|
|
4663
|
+
m.marginLeft = "-".concat(offset, "px");
|
|
4664
|
+
break;
|
|
4665
|
+
case 'bottom-right':
|
|
4666
|
+
m.marginTop = "".concat(offset, "px");
|
|
4667
|
+
m.marginLeft = "".concat(w + offset, "px");
|
|
4668
|
+
break;
|
|
4669
|
+
case 'top':
|
|
4670
|
+
default:
|
|
4671
|
+
m.marginTop = "-".concat(h + offset, "px");
|
|
4672
|
+
break;
|
|
4673
|
+
}
|
|
4674
|
+
return m;
|
|
4675
|
+
}
|
|
4676
|
+
var MlMarker = function (_a) {
|
|
4677
|
+
var _b = _a.passEventsThrough, passEventsThrough = _b === void 0 ? true : _b, _c = _a.contentOffset, contentOffset = _c === void 0 ? 5 : _c, props = __rest(_a, ["passEventsThrough", "contentOffset"]);
|
|
4611
4678
|
var mapHook = useMap({
|
|
4612
4679
|
mapId: props.mapId,
|
|
4613
4680
|
waitForLayer: props.insertBeforeLayer,
|
|
4614
4681
|
});
|
|
4615
|
-
var
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
});
|
|
4619
|
-
var iframe = React.useRef(null);
|
|
4620
|
-
var _a = React.useState({
|
|
4621
|
-
width: "400px",
|
|
4622
|
-
height: "500px",
|
|
4623
|
-
}), iframeDimensions = _a[0], setIframeDimensions = _a[1];
|
|
4624
|
-
var _b = React.useState(), markerPixelPos = _b[0], setMarkerPixelPos = _b[1];
|
|
4625
|
-
React.useEffect(function () {
|
|
4626
|
-
var _a, _b;
|
|
4627
|
-
if (!((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.project))
|
|
4628
|
-
return;
|
|
4629
|
-
var _pixelPos = mapHook.map.map.project([props.lng, props.lat]);
|
|
4630
|
-
setMarkerPixelPos(_pixelPos);
|
|
4631
|
-
}, [mapHook.map, props.lng, props.lat, mapState.viewport]);
|
|
4682
|
+
var _d = React.useState(null), marker = _d[0], setMarker = _d[1];
|
|
4683
|
+
var container = React.useRef(null);
|
|
4684
|
+
var iframeRef = React.useRef(null);
|
|
4632
4685
|
React.useEffect(function () {
|
|
4633
|
-
|
|
4634
|
-
if (!mapHook.map ||
|
|
4635
|
-
!((_d = (_c = (_b = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.document) === null || _c === void 0 ? void 0 : _c.body) === null || _d === void 0 ? void 0 : _d.scrollHeight))
|
|
4686
|
+
if (!mapHook.map)
|
|
4636
4687
|
return;
|
|
4637
|
-
|
|
4638
|
-
var
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4688
|
+
container.current = document.createElement('div');
|
|
4689
|
+
var defaultMarkerStyle = {
|
|
4690
|
+
width: '12px',
|
|
4691
|
+
height: '12px',
|
|
4692
|
+
background: 'linear-gradient(135deg, rgb(186, 208, 218) 0%, rgb(96, 209, 253) 100%)',
|
|
4693
|
+
border: '1px solid rgba(255, 255, 255, 0.7)',
|
|
4694
|
+
boxShadow: '0 2px 6px rgba(90, 0, 0, 0.2), 0 0 0 2px rgba(240, 147, 251, 0.2)',
|
|
4695
|
+
borderRadius: '50%',
|
|
4696
|
+
};
|
|
4697
|
+
var markerStyle = __assign(__assign({}, defaultMarkerStyle), props.markerStyle);
|
|
4698
|
+
var maplibreMarker = new maplibregl.Marker({
|
|
4699
|
+
element: container.current,
|
|
4700
|
+
anchor: 'center',
|
|
4701
|
+
})
|
|
4702
|
+
.setLngLat([props.lng, props.lat])
|
|
4703
|
+
.addTo(mapHook.map.map);
|
|
4704
|
+
setMarker(maplibreMarker);
|
|
4705
|
+
var markerDot = document.createElement('div');
|
|
4706
|
+
Object.entries(markerStyle).forEach(function (_a) {
|
|
4707
|
+
var key = _a[0], value = _a[1];
|
|
4708
|
+
markerDot.style.setProperty(key.replace(/([A-Z])/g, '-$1').toLowerCase(), String(value));
|
|
4645
4709
|
});
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4710
|
+
container.current.appendChild(markerDot);
|
|
4711
|
+
return function () {
|
|
4712
|
+
var _a;
|
|
4713
|
+
markerDot.remove();
|
|
4714
|
+
maplibreMarker.remove();
|
|
4715
|
+
(_a = container.current) === null || _a === void 0 ? void 0 : _a.remove();
|
|
4716
|
+
};
|
|
4717
|
+
}, [mapHook.map, props.lng, props.lat, props.markerStyle, props.anchor]);
|
|
4718
|
+
React.useEffect(function () {
|
|
4719
|
+
if (marker) {
|
|
4720
|
+
marker.setLngLat([props.lng, props.lat]);
|
|
4721
|
+
}
|
|
4722
|
+
}, [marker, props.lng, props.lat]);
|
|
4723
|
+
function handleIframeLoad() {
|
|
4724
|
+
var _a, _b, _c;
|
|
4725
|
+
var iframeDoc = (_b = (_a = iframeRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.document;
|
|
4726
|
+
if (iframeDoc && ((_c = iframeRef.current) === null || _c === void 0 ? void 0 : _c.parentElement)) {
|
|
4727
|
+
var scrollHeight = iframeDoc.documentElement.scrollHeight;
|
|
4728
|
+
iframeRef.current.parentElement.style.height = "".concat(scrollHeight, "px");
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
return (container.current &&
|
|
4732
|
+
ReactDOM.createPortal(React.createElement(material.Box, { sx: __assign(__assign(__assign({ position: 'absolute', display: 'flex', width: '300px', maxHeight: '500px', opacity: passEventsThrough ? 1 : 0.7, zIndex: -1, transform: getBoxTransform(props.anchor) }, getBoxMargins(props.anchor, contentOffset, props.markerStyle)), { pointerEvents: passEventsThrough ? 'none' : 'auto', '&:hover': {
|
|
4669
4733
|
opacity: 1,
|
|
4670
|
-
},
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4734
|
+
} }), props.containerStyle) },
|
|
4735
|
+
React.createElement("iframe", { ref: iframeRef, onLoad: handleIframeLoad, style: __assign({ width: '100%', borderStyle: 'none' }, props.iframeStyle), srcDoc: "<div>\n\t<style>\n\t\tbody {\n\t\t\t".concat(Object.entries(props.iframeBodyStyle || {})
|
|
4736
|
+
.map(function (_a) {
|
|
4737
|
+
var key = _a[0], val = _a[1];
|
|
4738
|
+
return "".concat(key.replace(/([A-Z])/g, '-$1').toLowerCase(), ": ").concat(val, ";");
|
|
4739
|
+
})
|
|
4740
|
+
.join(' '), "\n\t\t}\n\t</style>\n\t").concat(props.content || '', "\n</div>"), sandbox: "allow-same-origin allow-popups-to-escape-sandbox allow-scripts", title: mapHook.componentId })), container.current));
|
|
4677
4741
|
};
|
|
4678
4742
|
|
|
4679
4743
|
/**
|
|
@@ -6952,37 +7016,53 @@ var sketchTools = [
|
|
|
6952
7016
|
*
|
|
6953
7017
|
*/
|
|
6954
7018
|
var MlSketchTool = function (props) {
|
|
6955
|
-
var _a, _b;
|
|
6956
7019
|
var mapHook = useMap({
|
|
6957
7020
|
mapId: props.mapId,
|
|
6958
7021
|
waitForLayer: props.insertBeforeLayer,
|
|
6959
7022
|
});
|
|
6960
|
-
var
|
|
6961
|
-
var
|
|
7023
|
+
var _a = React.useState(), hoveredGeometry = _a[0], setHoveredGeometry = _a[1];
|
|
7024
|
+
var _b = React.useState({
|
|
6962
7025
|
activeGeometryIndex: undefined,
|
|
6963
7026
|
selectedGeoJson: undefined,
|
|
6964
7027
|
geometries: [],
|
|
6965
7028
|
drawMode: undefined,
|
|
6966
|
-
}), sketchState =
|
|
7029
|
+
}), sketchState = _b[0], setSketchState = _b[1];
|
|
7030
|
+
console.log(sketchState);
|
|
6967
7031
|
React.useEffect(function () {
|
|
6968
7032
|
if (!(typeof props.onChange === 'function'))
|
|
6969
7033
|
return;
|
|
6970
7034
|
props.onChange(sketchState);
|
|
6971
7035
|
}, [sketchState, props.onChange]);
|
|
6972
7036
|
var buttonStyle = __assign({}, props.buttonStyleOverride);
|
|
7037
|
+
// const buttonClickHandler = (buttonDrawMode: keyof MapboxDraw.Modes) => {
|
|
7038
|
+
// setSketchState((_state) => ({
|
|
7039
|
+
// drawMode: _state.drawMode !== buttonDrawMode ? buttonDrawMode : undefined,
|
|
7040
|
+
// geometries: _state.geometries,
|
|
7041
|
+
// activeGeometryIndex: undefined,
|
|
7042
|
+
// selectedGeoJson: undefined,
|
|
7043
|
+
// }));
|
|
7044
|
+
// };
|
|
6973
7045
|
var buttonClickHandler = function (buttonDrawMode) {
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
activeGeometryIndex: undefined,
|
|
6978
|
-
|
|
6979
|
-
|
|
7046
|
+
var modeRef = undefined;
|
|
7047
|
+
setSketchState(function (prevState) {
|
|
7048
|
+
modeRef = prevState.drawMode;
|
|
7049
|
+
return __assign(__assign({}, prevState), { drawMode: undefined, activeGeometryIndex: undefined, selectedGeoJson: undefined });
|
|
7050
|
+
});
|
|
7051
|
+
requestAnimationFrame(function () {
|
|
7052
|
+
setSketchState(function (prevState) {
|
|
7053
|
+
if ((modeRef === 'draw_polygon' || modeRef === 'draw_line_string') &&
|
|
7054
|
+
buttonDrawMode === 'draw_point') {
|
|
7055
|
+
return __assign(__assign({}, prevState), { drawMode: undefined });
|
|
7056
|
+
}
|
|
7057
|
+
return __assign(__assign({}, prevState), { drawMode: buttonDrawMode });
|
|
7058
|
+
});
|
|
7059
|
+
});
|
|
6980
7060
|
};
|
|
6981
7061
|
var removeGeoJson = function (geoJson) {
|
|
6982
7062
|
setSketchState(function (_sketchState) {
|
|
6983
7063
|
var _geometries = __spreadArray([], _sketchState.geometries, true);
|
|
6984
7064
|
_geometries.splice(_geometries.indexOf(geoJson), 1);
|
|
6985
|
-
return __assign(__assign({}, _sketchState), { geometries: _geometries, activeGeometryIndex: _sketchState.activeGeometryIndex
|
|
7065
|
+
return __assign(__assign({}, _sketchState), { drawMode: undefined, geometries: _geometries, activeGeometryIndex: _sketchState.activeGeometryIndex
|
|
6986
7066
|
? _sketchState.activeGeometryIndex - 1
|
|
6987
7067
|
: undefined });
|
|
6988
7068
|
});
|
|
@@ -7019,6 +7099,7 @@ var MlSketchTool = function (props) {
|
|
|
7019
7099
|
React.createElement(ButtonGroup, null,
|
|
7020
7100
|
React.createElement(SketchToolButtons, null))),
|
|
7021
7101
|
sketchState.drawMode && (React.createElement(MlFeatureEditor, { mode: sketchState.drawMode, geojson: sketchState.selectedGeoJson, onChange: function (feature) {
|
|
7102
|
+
console.log(feature);
|
|
7022
7103
|
if (!(feature === null || feature === void 0 ? void 0 : feature[0]))
|
|
7023
7104
|
return;
|
|
7024
7105
|
setSketchState(function (_sketchState) {
|
|
@@ -7037,6 +7118,24 @@ var MlSketchTool = function (props) {
|
|
|
7037
7118
|
else {
|
|
7038
7119
|
_geometries[_sketchState.activeGeometryIndex] = feature[0];
|
|
7039
7120
|
}
|
|
7121
|
+
// Check if the geometry type is point and if the coordinates have changed to exit draw mode after editing
|
|
7122
|
+
var changedPoint = function () {
|
|
7123
|
+
var _a, _b, _c, _d;
|
|
7124
|
+
if (_sketchState.selectedGeoJson &&
|
|
7125
|
+
typeof _sketchState.activeGeometryIndex !== 'undefined' &&
|
|
7126
|
+
_sketchState.geometries[_sketchState.activeGeometryIndex] &&
|
|
7127
|
+
_sketchState.geometries[_sketchState.activeGeometryIndex].geometry.type ===
|
|
7128
|
+
'Point') {
|
|
7129
|
+
var selectedCoords = (_b = (_a = _sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.geometry) === null || _b === void 0 ? void 0 : _b.coordinates;
|
|
7130
|
+
var activeCoords = (_d = (_c = _sketchState.geometries[_sketchState.activeGeometryIndex]) === null || _c === void 0 ? void 0 : _c.geometry) === null || _d === void 0 ? void 0 : _d.coordinates;
|
|
7131
|
+
// Compare coordinates
|
|
7132
|
+
return JSON.stringify(selectedCoords) !== JSON.stringify(activeCoords);
|
|
7133
|
+
}
|
|
7134
|
+
return false;
|
|
7135
|
+
};
|
|
7136
|
+
if (changedPoint()) {
|
|
7137
|
+
_sketchState.drawMode = undefined;
|
|
7138
|
+
}
|
|
7040
7139
|
return __assign(__assign({}, _sketchState), { geometries: _geometries });
|
|
7041
7140
|
});
|
|
7042
7141
|
}, onFinish: function () {
|
|
@@ -7056,46 +7155,73 @@ var MlSketchTool = function (props) {
|
|
|
7056
7155
|
}, onMouseLeave: function () {
|
|
7057
7156
|
setHoveredGeometry(undefined);
|
|
7058
7157
|
} },
|
|
7059
|
-
React.createElement(LayerListItem, { listItemSx: buttonStyle, configurable: true, layerComponent: React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: el, layerId: String(el.id)
|
|
7158
|
+
React.createElement(LayerListItem, { listItemSx: buttonStyle, configurable: true, layerComponent: React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: el, layerId: String(el.id), defaultPaintOverrides: {
|
|
7159
|
+
fill: { 'fill-opacity': 0.5 },
|
|
7160
|
+
} }), type: 'layer', name: String(el.id), description: el.geometry.type }),
|
|
7060
7161
|
React.createElement(system.Box, { sx: {
|
|
7061
7162
|
padding: '3px 30px',
|
|
7062
7163
|
} },
|
|
7063
7164
|
React.createElement(ButtonGroup, { size: "small" },
|
|
7064
|
-
React.createElement(
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
? el.geometry.
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7165
|
+
React.createElement(Tooltip, { title: "Center" },
|
|
7166
|
+
React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
|
|
7167
|
+
var _a;
|
|
7168
|
+
(_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setCenter(el.geometry.type === 'Point'
|
|
7169
|
+
? el.geometry.coordinates
|
|
7170
|
+
: turf__namespace.centerOfMass(el).geometry.coordinates);
|
|
7171
|
+
} },
|
|
7172
|
+
React.createElement(GpsFixedIcon, null))),
|
|
7173
|
+
React.createElement(Tooltip, { title: "Edit" },
|
|
7174
|
+
React.createElement(material.Button, { sx: __assign({ color: function (theme) {
|
|
7175
|
+
var _a;
|
|
7176
|
+
if (sketchState.drawMode === 'simple_select' &&
|
|
7177
|
+
((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
|
|
7178
|
+
return theme.palette.navigation.navColor;
|
|
7179
|
+
}
|
|
7180
|
+
else {
|
|
7181
|
+
return theme.palette.primary.main;
|
|
7182
|
+
}
|
|
7183
|
+
}, backgroundColor: function (theme) {
|
|
7184
|
+
var _a;
|
|
7185
|
+
if (sketchState.drawMode === 'simple_select' &&
|
|
7186
|
+
((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
|
|
7187
|
+
return theme.palette.primary.main;
|
|
7188
|
+
}
|
|
7189
|
+
else {
|
|
7190
|
+
return theme.palette.navigation.navColor;
|
|
7191
|
+
}
|
|
7192
|
+
} }, buttonStyle), onClick: function () {
|
|
7193
|
+
setSketchState(function (_sketchState) {
|
|
7194
|
+
var _a;
|
|
7195
|
+
var newDrawMode = _sketchState.drawMode === 'simple_select' &&
|
|
7196
|
+
((_a = _sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id
|
|
7197
|
+
? undefined
|
|
7198
|
+
: 'simple_select';
|
|
7199
|
+
return __assign(__assign({}, _sketchState), { selectedGeoJson: el, activeGeometryIndex: _sketchState.geometries.indexOf(el), drawMode: newDrawMode });
|
|
7200
|
+
});
|
|
7201
|
+
} },
|
|
7202
|
+
React.createElement(EditIcon, null))),
|
|
7203
|
+
React.createElement(Tooltip, { title: "Delete" },
|
|
7204
|
+
React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
|
|
7205
|
+
removeGeoJson(el);
|
|
7206
|
+
setHoveredGeometry(undefined);
|
|
7207
|
+
} },
|
|
7208
|
+
React.createElement(DeleteIcon, null))))))))); }),
|
|
7080
7209
|
hoveredGeometry && (React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: { type: 'FeatureCollection', features: [hoveredGeometry] }, layerId: 'highlightBorder', defaultPaintOverrides: {
|
|
7081
7210
|
circle: {
|
|
7082
|
-
'circle-color': '#
|
|
7083
|
-
'circle-opacity': 0.
|
|
7211
|
+
'circle-color': '#000000',
|
|
7212
|
+
'circle-opacity': 0.2,
|
|
7084
7213
|
'circle-radius': 10,
|
|
7085
7214
|
},
|
|
7086
7215
|
line: {
|
|
7087
|
-
'line-color': '#
|
|
7088
|
-
'line-opacity': 0.
|
|
7216
|
+
'line-color': '#000000',
|
|
7217
|
+
'line-opacity': 0.2,
|
|
7089
7218
|
'line-width': 10,
|
|
7090
7219
|
},
|
|
7091
7220
|
fill: {
|
|
7092
|
-
'fill-color': '#
|
|
7093
|
-
'fill-opacity': 0.
|
|
7221
|
+
'fill-color': '#000000',
|
|
7222
|
+
'fill-opacity': 0.2,
|
|
7094
7223
|
},
|
|
7095
|
-
} })))
|
|
7096
|
-
sketchState.drawMode === 'simple_select' && (React.createElement(material.Typography, { sx: { fontSize: '0.6em' } },
|
|
7097
|
-
"Edit ", (_b = (_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.geometry) === null || _b === void 0 ? void 0 :
|
|
7098
|
-
_b.type))));
|
|
7224
|
+
} })))));
|
|
7099
7225
|
};
|
|
7100
7226
|
MlSketchTool.defaultProps = {
|
|
7101
7227
|
mapId: undefined,
|