@mapcomponents/react-maplibre 1.0.11 → 1.1.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/dist/index.cjs.js +69 -63
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +69 -63
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/MapLibreMap/MapLibreMap.d.ts +4 -1
- package/dist/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.d.ts +1 -1
- package/dist/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +1 -1
- package/dist/src/components/MlSpatialElevationProfile/util/getElevationData.d.ts +2 -1
- package/dist/src/components/MlTemporalController/utils/paintPicker.d.ts +29 -29
- package/dist/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +2 -2
- package/dist/src/components/MlUseMapDebugger/MlUseMapDebugger.d.ts +5 -2
- package/dist/src/contexts/MapContext.d.ts +3 -1
- package/dist/src/decorators/MapContextDecorator.d.ts +1 -1
- package/dist/src/decorators/MapContextReduxStoreDecorator.d.ts +1 -1
- package/dist/src/hooks/useExportMap/index.d.ts +1 -1
- package/dist/src/hooks/useFeatureEditor/useFeatureEditor.d.ts +1 -1
- package/dist/src/protocol_handlers/mbtiles.d.ts +42 -1
- package/dist/src/ui_components/LayerList/util/LayerListItemVectorLayer.d.ts +1 -3
- package/dist/src/ui_components/MapcomponentsTheme.d.ts +1 -1
- package/eslint.config.mjs +73 -0
- package/package.json +74 -66
package/dist/index.cjs.js
CHANGED
|
@@ -204,7 +204,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
204
204
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
208
207
|
var MapLibreGlWrapper = /** @class */ (function () {
|
|
209
208
|
function MapLibreGlWrapper(props) {
|
|
210
209
|
var _this = this;
|
|
@@ -506,7 +505,6 @@ var MapLibreGlWrapper = /** @class */ (function () {
|
|
|
506
505
|
self.initRegisteredElements(componentId);
|
|
507
506
|
self.registeredElements[componentId].events.push(_arguments);
|
|
508
507
|
}
|
|
509
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
510
508
|
// @ts-ignore
|
|
511
509
|
(_a = self.map).on.apply(_a, _arguments);
|
|
512
510
|
return _this;
|
|
@@ -554,7 +552,6 @@ var MapLibreGlWrapper = /** @class */ (function () {
|
|
|
554
552
|
// cleanup events
|
|
555
553
|
self.registeredElements[componentId].events.forEach(function (item) {
|
|
556
554
|
var _a;
|
|
557
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
558
555
|
// @ts-ignore
|
|
559
556
|
(_a = self.map).off.apply(_a, item);
|
|
560
557
|
});
|
|
@@ -1087,8 +1084,8 @@ var defaultProps$1 = {
|
|
|
1087
1084
|
*/
|
|
1088
1085
|
var MapLibreMap = function (props) {
|
|
1089
1086
|
var _a, _b;
|
|
1090
|
-
var mapRef = React.useRef();
|
|
1091
|
-
var mapContainer = React.useRef();
|
|
1087
|
+
var mapRef = React.useRef(null);
|
|
1088
|
+
var mapContainer = React.useRef(null);
|
|
1092
1089
|
var mapContext = React.useContext(MapContext);
|
|
1093
1090
|
var mapIdRef = React.useRef(props.mapId);
|
|
1094
1091
|
var initializedRef = React.useRef(false);
|
|
@@ -1102,7 +1099,7 @@ var MapLibreMap = function (props) {
|
|
|
1102
1099
|
if (mapRef.current) {
|
|
1103
1100
|
(_b = (_a = mapRef.current.map) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1104
1101
|
mapRef.current.cancelled = true;
|
|
1105
|
-
mapRef.current =
|
|
1102
|
+
mapRef.current = null;
|
|
1106
1103
|
}
|
|
1107
1104
|
};
|
|
1108
1105
|
}, []);
|
|
@@ -1156,11 +1153,11 @@ function useMapState(props) {
|
|
|
1156
1153
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1157
1154
|
var mapContext = React.useContext(MapContext);
|
|
1158
1155
|
var initializedRef = React.useRef(false);
|
|
1159
|
-
var mapRef = React.useRef();
|
|
1156
|
+
var mapRef = React.useRef(null);
|
|
1160
1157
|
var _a = React.useState(), viewport = _a[0], setViewport = _a[1];
|
|
1161
1158
|
var viewportRef = React.useRef(undefined);
|
|
1162
1159
|
var _b = React.useState([]), layers = _b[0], setLayers = _b[1];
|
|
1163
|
-
var layersRef = React.useRef();
|
|
1160
|
+
var layersRef = React.useRef("");
|
|
1164
1161
|
//const mapRef = useRef(props.map);
|
|
1165
1162
|
var componentId = React.useRef(uuid.v4());
|
|
1166
1163
|
/**
|
|
@@ -1200,7 +1197,7 @@ function useMapState(props) {
|
|
|
1200
1197
|
// cleanup all event listeners
|
|
1201
1198
|
if (mapRef.current) {
|
|
1202
1199
|
mapRef.current.cleanup(_componentId);
|
|
1203
|
-
mapRef.current =
|
|
1200
|
+
mapRef.current = null;
|
|
1204
1201
|
}
|
|
1205
1202
|
initializedRef.current = false;
|
|
1206
1203
|
};
|
|
@@ -1267,7 +1264,7 @@ function useMap(props) {
|
|
|
1267
1264
|
includeBaseLayers: true,
|
|
1268
1265
|
},
|
|
1269
1266
|
});
|
|
1270
|
-
var mapRef = React.useRef();
|
|
1267
|
+
var mapRef = React.useRef(null);
|
|
1271
1268
|
var componentId = React.useRef(uuid.v4());
|
|
1272
1269
|
var cleanup = function () {
|
|
1273
1270
|
if (mapRef.current) {
|
|
@@ -1277,13 +1274,13 @@ function useMap(props) {
|
|
|
1277
1274
|
React.useEffect(function () {
|
|
1278
1275
|
return function () {
|
|
1279
1276
|
cleanup();
|
|
1280
|
-
mapRef.current =
|
|
1277
|
+
mapRef.current = null;
|
|
1281
1278
|
};
|
|
1282
1279
|
}, []);
|
|
1283
1280
|
React.useEffect(function () {
|
|
1284
1281
|
var _a;
|
|
1285
1282
|
if (mapRef.current && mapRef.current.cancelled === true) {
|
|
1286
|
-
mapRef.current =
|
|
1283
|
+
mapRef.current = null;
|
|
1287
1284
|
setState({ map: undefined, ready: false });
|
|
1288
1285
|
}
|
|
1289
1286
|
if (mapRef.current || !mapContext.mapExists(props === null || props === void 0 ? void 0 : props.mapId))
|
|
@@ -1397,6 +1394,8 @@ var createExport = function (options) {
|
|
|
1397
1394
|
bearing: 0,
|
|
1398
1395
|
pitch: 0,
|
|
1399
1396
|
interactive: false,
|
|
1397
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1398
|
+
// @ts-expect-error
|
|
1400
1399
|
preserveDrawingBuffer: true,
|
|
1401
1400
|
fadeDuration: 0,
|
|
1402
1401
|
attributionControl: false,
|
|
@@ -1607,7 +1606,7 @@ var PdfContextProvider = function (_a) {
|
|
|
1607
1606
|
orientation: 'portrait',
|
|
1608
1607
|
fixedScale: 0,
|
|
1609
1608
|
}), options = _d[0], setOptions = _d[1];
|
|
1610
|
-
var geojsonRef = React.useRef();
|
|
1609
|
+
var geojsonRef = React.useRef(null);
|
|
1611
1610
|
var template = React.useMemo(function () {
|
|
1612
1611
|
if (typeof PdfTemplates[format][quality] !== 'undefined') {
|
|
1613
1612
|
return options.orientation === 'portrait'
|
|
@@ -1670,7 +1669,7 @@ function PdfPreview(props) {
|
|
|
1670
1669
|
var _a;
|
|
1671
1670
|
var mapState = useMapState({ mapId: props.mapId, watch: { layers: false, viewport: true } });
|
|
1672
1671
|
var targetRef = React.useRef(null);
|
|
1673
|
-
var fixedScaleRef = React.useRef();
|
|
1672
|
+
var fixedScaleRef = React.useRef(null);
|
|
1674
1673
|
var moveableRef = React.useRef(null);
|
|
1675
1674
|
var mapContainerRef = React.useRef(document.querySelector('.mapContainer'));
|
|
1676
1675
|
//const [transform, setTransform] = useState('translate(452.111px, 15.6148px)');
|
|
@@ -1914,7 +1913,6 @@ function PdfForm(props) {
|
|
|
1914
1913
|
var _c = React.useState(false), loading = _c[0], setLoading = _c[1];
|
|
1915
1914
|
var pdfContext = React.useContext(PdfContext);
|
|
1916
1915
|
var mapHook = useMap({
|
|
1917
|
-
// eslint-disable-next-line react/prop-types
|
|
1918
1916
|
mapId: props.mapId,
|
|
1919
1917
|
});
|
|
1920
1918
|
var mapExporter = useExportMap({ mapId: props.mapId });
|
|
@@ -1943,7 +1941,6 @@ function PdfForm(props) {
|
|
|
1943
1941
|
.then(function (res) {
|
|
1944
1942
|
if (typeof props.onCreatePdf === 'function') {
|
|
1945
1943
|
res.formData = new FormData(document.getElementById('createPdfFormID'));
|
|
1946
|
-
console.log('testlog');
|
|
1947
1944
|
props.onCreatePdf(res);
|
|
1948
1945
|
}
|
|
1949
1946
|
setLoading(false);
|
|
@@ -2253,7 +2250,7 @@ function featureEditorStyle() {
|
|
|
2253
2250
|
* GeoJson Feature editor that allows to create or manipulate GeoJson data
|
|
2254
2251
|
*/
|
|
2255
2252
|
var useFeatureEditor = function (props) {
|
|
2256
|
-
var draw = React.useRef();
|
|
2253
|
+
var draw = React.useRef(null);
|
|
2257
2254
|
var mapHook = useMap({
|
|
2258
2255
|
mapId: props.mapId,
|
|
2259
2256
|
waitForLayer: props.insertBeforeLayer,
|
|
@@ -3316,7 +3313,7 @@ function LayerPropertyForm$1(_a) {
|
|
|
3316
3313
|
case 'slider':
|
|
3317
3314
|
return (React.createElement(React.Fragment, { key: key },
|
|
3318
3315
|
label,
|
|
3319
|
-
React.createElement(material.Slider, __assign({}, inputPropsByPropKey$1[key], {
|
|
3316
|
+
React.createElement(material.Slider, __assign({}, inputPropsByPropKey$1[key], { value: paintProps[key], valueLabelDisplay: "auto", onChange: function (_ev, value) {
|
|
3320
3317
|
if (value) {
|
|
3321
3318
|
setPaintProps(function (current) {
|
|
3322
3319
|
var _a;
|
|
@@ -4011,16 +4008,12 @@ var MlNavigationTools = function (props) {
|
|
|
4011
4008
|
var zoomIn = React.useCallback(function () {
|
|
4012
4009
|
if (!mapHook.map)
|
|
4013
4010
|
return;
|
|
4014
|
-
|
|
4015
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform._zoom + 0.5 });
|
|
4016
|
-
}
|
|
4011
|
+
mapHook.map.easeTo({ zoom: mapHook.map.getZoom() + 0.5 });
|
|
4017
4012
|
}, [mapHook.map]);
|
|
4018
4013
|
var zoomOut = React.useCallback(function () {
|
|
4019
4014
|
if (!mapHook.map)
|
|
4020
4015
|
return;
|
|
4021
|
-
|
|
4022
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform._zoom - 0.5 });
|
|
4023
|
-
}
|
|
4016
|
+
mapHook.map.easeTo({ zoom: mapHook.map.getZoom() - 0.5 });
|
|
4024
4017
|
}, [mapHook.map]);
|
|
4025
4018
|
var adjustPitch = React.useCallback(function () {
|
|
4026
4019
|
if (!mapHook.map)
|
|
@@ -4386,12 +4379,12 @@ var MlLayerSwipe = function (props) {
|
|
|
4386
4379
|
document.removeEventListener('mouseup', onMouseUp);
|
|
4387
4380
|
};
|
|
4388
4381
|
function adjustWindowSize() {
|
|
4389
|
-
var clipWidth = mapContext.maps[props.map2Id]
|
|
4382
|
+
var clipWidth = parseFloat(mapContext.maps[props.map2Id]
|
|
4390
4383
|
.getContainer()
|
|
4391
4384
|
.style.clip.split(',')[1]
|
|
4392
|
-
.replace('px', '');
|
|
4385
|
+
.replace('px', ''));
|
|
4393
4386
|
var canvasWidth = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect().width;
|
|
4394
|
-
if (
|
|
4387
|
+
if (clipWidth < canvasWidth) {
|
|
4395
4388
|
var newPosition = parseFloat(((clipWidth / canvasWidth) * 100).toFixed(2));
|
|
4396
4389
|
setSwipeX(newPosition);
|
|
4397
4390
|
}
|
|
@@ -4592,7 +4585,7 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4592
4585
|
});
|
|
4593
4586
|
var initializedRef = React.useRef(false);
|
|
4594
4587
|
// transition effect variables
|
|
4595
|
-
var oldGeojsonRef = React.useRef();
|
|
4588
|
+
var oldGeojsonRef = React.useRef(null);
|
|
4596
4589
|
var transitionInProgressRef = React.useRef(false);
|
|
4597
4590
|
var transitionTimeoutRef = React.useRef(undefined);
|
|
4598
4591
|
var currentTransitionStepRef = React.useRef(false);
|
|
@@ -4622,7 +4615,9 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4622
4615
|
transitionGeojsonCommonDataRef.current = [];
|
|
4623
4616
|
transitionToGeojson();
|
|
4624
4617
|
}
|
|
4625
|
-
|
|
4618
|
+
if (props.geojson) {
|
|
4619
|
+
oldGeojsonRef.current = props.geojson;
|
|
4620
|
+
}
|
|
4626
4621
|
}, [mapHook.map, transitionToGeojson, props]);
|
|
4627
4622
|
var startTransition = React.useCallback(function () {
|
|
4628
4623
|
if (props.type === 'line' &&
|
|
@@ -5414,7 +5409,7 @@ var MlShareMapState = function (props) {
|
|
|
5414
5409
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5415
5410
|
var mapContext = React.useContext(MapContext);
|
|
5416
5411
|
var initializedRef = React.useRef(false);
|
|
5417
|
-
var mapRef = React.useRef();
|
|
5412
|
+
var mapRef = React.useRef(null);
|
|
5418
5413
|
var _a = React.useState(undefined), map = _a[0], setMap = _a[1];
|
|
5419
5414
|
var layersFromUrlParamsRef = React.useRef({});
|
|
5420
5415
|
var componentId = React.useRef((props.idPrefix ? props.idPrefix : 'MlShareMapState-') + uuid.v4());
|
|
@@ -5429,7 +5424,7 @@ var MlShareMapState = function (props) {
|
|
|
5429
5424
|
},
|
|
5430
5425
|
});
|
|
5431
5426
|
var allStatesRestoredRef = React.useRef(false);
|
|
5432
|
-
var layerStatesRestored = React.useRef();
|
|
5427
|
+
var layerStatesRestored = React.useRef(null);
|
|
5433
5428
|
var restoredStatesRef = React.useRef({
|
|
5434
5429
|
viewport: {
|
|
5435
5430
|
center: false,
|
|
@@ -5475,7 +5470,7 @@ var MlShareMapState = function (props) {
|
|
|
5475
5470
|
// check for the existence of map.style before calling getLayer or getSource
|
|
5476
5471
|
if (mapRef.current) {
|
|
5477
5472
|
mapRef.current.cleanup(_componentId);
|
|
5478
|
-
mapRef.current =
|
|
5473
|
+
mapRef.current = null;
|
|
5479
5474
|
}
|
|
5480
5475
|
initializedRef.current = false;
|
|
5481
5476
|
};
|
|
@@ -5513,7 +5508,7 @@ var MlShareMapState = function (props) {
|
|
|
5513
5508
|
if (!((_a = mapState === null || mapState === void 0 ? void 0 : mapState.layers) === null || _a === void 0 ? void 0 : _a.length))
|
|
5514
5509
|
return;
|
|
5515
5510
|
if (typeof layerStatesRestored.current === 'undefined') {
|
|
5516
|
-
layerStatesRestored.current =
|
|
5511
|
+
layerStatesRestored.current = null;
|
|
5517
5512
|
(_b = initialUrlParams === null || initialUrlParams === void 0 ? void 0 : initialUrlParams.layers) === null || _b === void 0 ? void 0 : _b.forEach(function (layer) {
|
|
5518
5513
|
var _a;
|
|
5519
5514
|
if ((_a = layerStatesRestored.current) === null || _a === void 0 ? void 0 : _a[layer.id]) {
|
|
@@ -5627,7 +5622,7 @@ function getElevationData(_geojsonInfo, elevationFactor) {
|
|
|
5627
5622
|
_geojsonInfo.line.geometry.coordinates.forEach(function (coordinate, index) {
|
|
5628
5623
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5629
5624
|
//points.push(point);
|
|
5630
|
-
if (_geojsonInfo.line.geometry.coordinates[index + 1]) {
|
|
5625
|
+
if (_geojsonInfo.line.geometry.coordinates[index + 1] && Array.isArray(coordinate)) {
|
|
5631
5626
|
var wayLength = turf.distance([coordinate[0], coordinate[1]], [
|
|
5632
5627
|
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
5633
5628
|
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
@@ -5796,7 +5791,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5796
5791
|
var layerPaintConfString = JSON.stringify(layer.paint);
|
|
5797
5792
|
if (layerPaintConfString !== layerPaintConfsRef.current[layer.id]) {
|
|
5798
5793
|
for (var paintKey in layer.paint) {
|
|
5799
|
-
mapHook.map.
|
|
5794
|
+
mapHook.map.setPaintProperty(layer.id, paintKey, layer.paint[paintKey]);
|
|
5800
5795
|
}
|
|
5801
5796
|
}
|
|
5802
5797
|
layerPaintConfsRef.current[layer.id] = layerPaintConfString;
|
|
@@ -5804,7 +5799,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5804
5799
|
var layerLayoutConfString = JSON.stringify(layer.layout);
|
|
5805
5800
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[layer.id]) {
|
|
5806
5801
|
for (var layoutKey in layer.layout) {
|
|
5807
|
-
mapHook.map.
|
|
5802
|
+
mapHook.map.setLayoutProperty(layer.id, layoutKey, layer.layout[layoutKey]);
|
|
5808
5803
|
}
|
|
5809
5804
|
}
|
|
5810
5805
|
layerLayoutConfsRef.current[layer.id] = layerLayoutConfString;
|
|
@@ -6690,7 +6685,7 @@ function TemporalControllerPlayer(props) {
|
|
|
6690
6685
|
var _a = React.useState(props.currentVal), currentVal = _a[0], setCurrentVal = _a[1];
|
|
6691
6686
|
var _b = React.useState(props.isPlaying), isPlaying = _b[0], setIsPlaying = _b[1];
|
|
6692
6687
|
var range = props.maxVal - props.minVal;
|
|
6693
|
-
var intervalRef = React.useRef();
|
|
6688
|
+
var intervalRef = React.useRef(null);
|
|
6694
6689
|
var mediaIsMobile = material.useMediaQuery(function (theme) { return theme.breakpoints.down('md'); });
|
|
6695
6690
|
React.useEffect(function () {
|
|
6696
6691
|
return function () {
|
|
@@ -6710,7 +6705,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6710
6705
|
}
|
|
6711
6706
|
intervalRef.current = setInterval(function () {
|
|
6712
6707
|
if (counter >= range) {
|
|
6713
|
-
|
|
6708
|
+
if (intervalRef.current)
|
|
6709
|
+
clearInterval(intervalRef.current);
|
|
6714
6710
|
setIsPlaying(false);
|
|
6715
6711
|
}
|
|
6716
6712
|
else {
|
|
@@ -6728,18 +6724,21 @@ function TemporalControllerPlayer(props) {
|
|
|
6728
6724
|
else {
|
|
6729
6725
|
setIsPlaying(false);
|
|
6730
6726
|
if (isPlaying) {
|
|
6731
|
-
|
|
6727
|
+
if (intervalRef.current)
|
|
6728
|
+
clearInterval(intervalRef.current);
|
|
6732
6729
|
}
|
|
6733
6730
|
}
|
|
6734
6731
|
};
|
|
6735
6732
|
var handleStop = function () {
|
|
6736
|
-
|
|
6733
|
+
if (intervalRef.current)
|
|
6734
|
+
clearInterval(intervalRef.current);
|
|
6737
6735
|
setCurrentVal(props.minVal);
|
|
6738
6736
|
setIsPlaying(false);
|
|
6739
6737
|
};
|
|
6740
6738
|
var handleFastRewind = function () {
|
|
6741
6739
|
if (isPlaying) {
|
|
6742
|
-
|
|
6740
|
+
if (intervalRef.current)
|
|
6741
|
+
clearInterval(intervalRef.current);
|
|
6743
6742
|
setCurrentVal(currentVal - range / 10);
|
|
6744
6743
|
play();
|
|
6745
6744
|
}
|
|
@@ -6749,7 +6748,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6749
6748
|
};
|
|
6750
6749
|
var handleFastForward = function () {
|
|
6751
6750
|
if (isPlaying) {
|
|
6752
|
-
|
|
6751
|
+
if (intervalRef.current)
|
|
6752
|
+
clearInterval(intervalRef.current);
|
|
6753
6753
|
setCurrentVal(currentVal + range / 10);
|
|
6754
6754
|
play();
|
|
6755
6755
|
}
|
|
@@ -6764,7 +6764,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6764
6764
|
}
|
|
6765
6765
|
else {
|
|
6766
6766
|
if (e) {
|
|
6767
|
-
|
|
6767
|
+
if (intervalRef.current)
|
|
6768
|
+
clearInterval(intervalRef.current);
|
|
6768
6769
|
setCurrentVal(newValue);
|
|
6769
6770
|
play();
|
|
6770
6771
|
}
|
|
@@ -6890,13 +6891,14 @@ var MlTemporalController = function (props) {
|
|
|
6890
6891
|
setCurrentVal(props.initialVal);
|
|
6891
6892
|
}
|
|
6892
6893
|
}, []);
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6894
|
+
React.useEffect(function () {
|
|
6895
|
+
if (typeof props.onStateChange === 'function') {
|
|
6896
|
+
props.onStateChange({
|
|
6897
|
+
current: currentVal,
|
|
6898
|
+
paint: paint,
|
|
6899
|
+
});
|
|
6900
|
+
}
|
|
6901
|
+
}, [props.onStateChange]);
|
|
6900
6902
|
// Fit map to bbox
|
|
6901
6903
|
React.useEffect(function () {
|
|
6902
6904
|
var _a;
|
|
@@ -7095,7 +7097,7 @@ var MlSketchTool = function (props) {
|
|
|
7095
7097
|
};
|
|
7096
7098
|
return (React.createElement(React.Fragment, null,
|
|
7097
7099
|
React.createElement(Tooltip, { title: el.name },
|
|
7098
|
-
React.createElement(material.Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7100
|
+
React.createElement(material.Button, { key: el.name, sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7099
7101
|
backgroundColor: stateColor,
|
|
7100
7102
|
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
7101
7103
|
})));
|
|
@@ -7113,7 +7115,12 @@ var MlSketchTool = function (props) {
|
|
|
7113
7115
|
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
7114
7116
|
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
7115
7117
|
var tempFeature = feature[0];
|
|
7116
|
-
tempFeature
|
|
7118
|
+
if (tempFeature && tempFeature.properties) {
|
|
7119
|
+
tempFeature.properties.id = tempFeature.id;
|
|
7120
|
+
}
|
|
7121
|
+
else {
|
|
7122
|
+
console.error('tempFeature or tempFeature.properties is null or undefined');
|
|
7123
|
+
}
|
|
7117
7124
|
_sketchState.activeGeometryIndex = _geometries.length;
|
|
7118
7125
|
_geometries.push(tempFeature);
|
|
7119
7126
|
}
|
|
@@ -7173,7 +7180,7 @@ var MlSketchTool = function (props) {
|
|
|
7173
7180
|
},
|
|
7174
7181
|
fill: {
|
|
7175
7182
|
'fill-color': '#dd9900',
|
|
7176
|
-
'fill-opacity': 0.4
|
|
7183
|
+
'fill-opacity': 0.4,
|
|
7177
7184
|
},
|
|
7178
7185
|
} }))),
|
|
7179
7186
|
sketchState.drawMode === 'simple_select' && (React.createElement(material.Typography, { sx: { fontSize: '0.6em' } },
|
|
@@ -7198,7 +7205,7 @@ var useCameraFollowPath = function (props) {
|
|
|
7198
7205
|
var pitch = React.useRef(props.pitch);
|
|
7199
7206
|
var step = React.useRef(1);
|
|
7200
7207
|
var speed = React.useRef(props.speed);
|
|
7201
|
-
var timeoutId = React.useRef();
|
|
7208
|
+
var timeoutId = React.useRef(null);
|
|
7202
7209
|
var kmPerStep = props.kmPerStep || 0.01;
|
|
7203
7210
|
var routeDistance = turf__namespace.length(props.route);
|
|
7204
7211
|
var stepDuration = props.stepDuration || 70;
|
|
@@ -7540,7 +7547,6 @@ function convertOSM(params) {
|
|
|
7540
7547
|
});
|
|
7541
7548
|
});
|
|
7542
7549
|
}
|
|
7543
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7544
7550
|
var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7545
7551
|
var parsedParams, data;
|
|
7546
7552
|
return __generator(this, function (_a) {
|
|
@@ -7560,7 +7566,6 @@ var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, vo
|
|
|
7560
7566
|
|
|
7561
7567
|
function reduceFeatures(geojson) {
|
|
7562
7568
|
var newFeatures = [];
|
|
7563
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7564
7569
|
geojson.features.forEach(function (e) {
|
|
7565
7570
|
if (!e.features) {
|
|
7566
7571
|
newFeatures.push({
|
|
@@ -7593,6 +7598,7 @@ function convertTopojson(params) {
|
|
|
7593
7598
|
topoJsonData = JSON.parse(rawData);
|
|
7594
7599
|
}
|
|
7595
7600
|
catch (e) {
|
|
7601
|
+
console.error('Error converting topojson', e);
|
|
7596
7602
|
throw 'Invalid TopoJson';
|
|
7597
7603
|
}
|
|
7598
7604
|
// Convert the data
|
|
@@ -7601,15 +7607,16 @@ function convertTopojson(params) {
|
|
|
7601
7607
|
features: [],
|
|
7602
7608
|
};
|
|
7603
7609
|
if (topoJsonData.type === 'Topology' && topoJsonData.objects !== undefined) {
|
|
7610
|
+
var topoJsonDataObjects_1 = topoJsonData.objects;
|
|
7604
7611
|
// add the "fromObject" property in each topojson feature
|
|
7605
7612
|
Object.keys(topoJsonData.objects).map(function (key) {
|
|
7606
|
-
var _a, _b
|
|
7607
|
-
if ((
|
|
7608
|
-
(
|
|
7613
|
+
var _a, _b;
|
|
7614
|
+
if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].type) === 'GeometryCollection') {
|
|
7615
|
+
(_a = topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].geometries) === null || _a === void 0 ? void 0 : _a.forEach(function (e) { return (e.properties = __assign({ fromObject: key }, e.properties)); });
|
|
7609
7616
|
}
|
|
7610
|
-
else if ((
|
|
7611
|
-
((
|
|
7612
|
-
|
|
7617
|
+
else if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) &&
|
|
7618
|
+
((_b = topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) === null || _b === void 0 ? void 0 : _b.type) !== 'GeometryCollection') {
|
|
7619
|
+
topoJsonDataObjects_1[key].properties = __assign({ fromObject: key }, topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].properties);
|
|
7613
7620
|
}
|
|
7614
7621
|
});
|
|
7615
7622
|
//convert the data into a geoJson object
|
|
@@ -7680,7 +7687,6 @@ function convertXML(params) {
|
|
|
7680
7687
|
});
|
|
7681
7688
|
});
|
|
7682
7689
|
}
|
|
7683
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7684
7690
|
var XMLProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7685
7691
|
var parsedParams, data;
|
|
7686
7692
|
return __generator(this, function (_a) {
|