@mapcomponents/react-maplibre 1.0.11 → 1.1.0-1
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 +71 -61
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +71 -61
- 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,15 +4008,15 @@ var MlNavigationTools = function (props) {
|
|
|
4011
4008
|
var zoomIn = React.useCallback(function () {
|
|
4012
4009
|
if (!mapHook.map)
|
|
4013
4010
|
return;
|
|
4014
|
-
if (mapHook.map.transform.
|
|
4015
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform.
|
|
4011
|
+
if (mapHook.map.transform.zoom + 0.5 <= mapHook.map.transform.maxZoom) {
|
|
4012
|
+
mapHook.map.easeTo({ zoom: mapHook.map.transform.zoom + 0.5 });
|
|
4016
4013
|
}
|
|
4017
4014
|
}, [mapHook.map]);
|
|
4018
4015
|
var zoomOut = React.useCallback(function () {
|
|
4019
4016
|
if (!mapHook.map)
|
|
4020
4017
|
return;
|
|
4021
|
-
if (mapHook.map.transform.
|
|
4022
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform.
|
|
4018
|
+
if (mapHook.map.transform.zoom - 0.5 >= mapHook.map.transform.minZoom) {
|
|
4019
|
+
mapHook.map.easeTo({ zoom: mapHook.map.transform.zoom - 0.5 });
|
|
4023
4020
|
}
|
|
4024
4021
|
}, [mapHook.map]);
|
|
4025
4022
|
var adjustPitch = React.useCallback(function () {
|
|
@@ -4386,12 +4383,12 @@ var MlLayerSwipe = function (props) {
|
|
|
4386
4383
|
document.removeEventListener('mouseup', onMouseUp);
|
|
4387
4384
|
};
|
|
4388
4385
|
function adjustWindowSize() {
|
|
4389
|
-
var clipWidth = mapContext.maps[props.map2Id]
|
|
4386
|
+
var clipWidth = parseFloat(mapContext.maps[props.map2Id]
|
|
4390
4387
|
.getContainer()
|
|
4391
4388
|
.style.clip.split(',')[1]
|
|
4392
|
-
.replace('px', '');
|
|
4389
|
+
.replace('px', ''));
|
|
4393
4390
|
var canvasWidth = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect().width;
|
|
4394
|
-
if (
|
|
4391
|
+
if (clipWidth < canvasWidth) {
|
|
4395
4392
|
var newPosition = parseFloat(((clipWidth / canvasWidth) * 100).toFixed(2));
|
|
4396
4393
|
setSwipeX(newPosition);
|
|
4397
4394
|
}
|
|
@@ -4592,7 +4589,7 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4592
4589
|
});
|
|
4593
4590
|
var initializedRef = React.useRef(false);
|
|
4594
4591
|
// transition effect variables
|
|
4595
|
-
var oldGeojsonRef = React.useRef();
|
|
4592
|
+
var oldGeojsonRef = React.useRef(null);
|
|
4596
4593
|
var transitionInProgressRef = React.useRef(false);
|
|
4597
4594
|
var transitionTimeoutRef = React.useRef(undefined);
|
|
4598
4595
|
var currentTransitionStepRef = React.useRef(false);
|
|
@@ -4622,7 +4619,9 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4622
4619
|
transitionGeojsonCommonDataRef.current = [];
|
|
4623
4620
|
transitionToGeojson();
|
|
4624
4621
|
}
|
|
4625
|
-
|
|
4622
|
+
if (props.geojson) {
|
|
4623
|
+
oldGeojsonRef.current = props.geojson;
|
|
4624
|
+
}
|
|
4626
4625
|
}, [mapHook.map, transitionToGeojson, props]);
|
|
4627
4626
|
var startTransition = React.useCallback(function () {
|
|
4628
4627
|
if (props.type === 'line' &&
|
|
@@ -5414,7 +5413,7 @@ var MlShareMapState = function (props) {
|
|
|
5414
5413
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5415
5414
|
var mapContext = React.useContext(MapContext);
|
|
5416
5415
|
var initializedRef = React.useRef(false);
|
|
5417
|
-
var mapRef = React.useRef();
|
|
5416
|
+
var mapRef = React.useRef(null);
|
|
5418
5417
|
var _a = React.useState(undefined), map = _a[0], setMap = _a[1];
|
|
5419
5418
|
var layersFromUrlParamsRef = React.useRef({});
|
|
5420
5419
|
var componentId = React.useRef((props.idPrefix ? props.idPrefix : 'MlShareMapState-') + uuid.v4());
|
|
@@ -5429,7 +5428,7 @@ var MlShareMapState = function (props) {
|
|
|
5429
5428
|
},
|
|
5430
5429
|
});
|
|
5431
5430
|
var allStatesRestoredRef = React.useRef(false);
|
|
5432
|
-
var layerStatesRestored = React.useRef();
|
|
5431
|
+
var layerStatesRestored = React.useRef(null);
|
|
5433
5432
|
var restoredStatesRef = React.useRef({
|
|
5434
5433
|
viewport: {
|
|
5435
5434
|
center: false,
|
|
@@ -5475,7 +5474,7 @@ var MlShareMapState = function (props) {
|
|
|
5475
5474
|
// check for the existence of map.style before calling getLayer or getSource
|
|
5476
5475
|
if (mapRef.current) {
|
|
5477
5476
|
mapRef.current.cleanup(_componentId);
|
|
5478
|
-
mapRef.current =
|
|
5477
|
+
mapRef.current = null;
|
|
5479
5478
|
}
|
|
5480
5479
|
initializedRef.current = false;
|
|
5481
5480
|
};
|
|
@@ -5513,7 +5512,7 @@ var MlShareMapState = function (props) {
|
|
|
5513
5512
|
if (!((_a = mapState === null || mapState === void 0 ? void 0 : mapState.layers) === null || _a === void 0 ? void 0 : _a.length))
|
|
5514
5513
|
return;
|
|
5515
5514
|
if (typeof layerStatesRestored.current === 'undefined') {
|
|
5516
|
-
layerStatesRestored.current =
|
|
5515
|
+
layerStatesRestored.current = null;
|
|
5517
5516
|
(_b = initialUrlParams === null || initialUrlParams === void 0 ? void 0 : initialUrlParams.layers) === null || _b === void 0 ? void 0 : _b.forEach(function (layer) {
|
|
5518
5517
|
var _a;
|
|
5519
5518
|
if ((_a = layerStatesRestored.current) === null || _a === void 0 ? void 0 : _a[layer.id]) {
|
|
@@ -5627,7 +5626,7 @@ function getElevationData(_geojsonInfo, elevationFactor) {
|
|
|
5627
5626
|
_geojsonInfo.line.geometry.coordinates.forEach(function (coordinate, index) {
|
|
5628
5627
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5629
5628
|
//points.push(point);
|
|
5630
|
-
if (_geojsonInfo.line.geometry.coordinates[index + 1]) {
|
|
5629
|
+
if (_geojsonInfo.line.geometry.coordinates[index + 1] && Array.isArray(coordinate)) {
|
|
5631
5630
|
var wayLength = turf.distance([coordinate[0], coordinate[1]], [
|
|
5632
5631
|
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
5633
5632
|
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
@@ -5796,7 +5795,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5796
5795
|
var layerPaintConfString = JSON.stringify(layer.paint);
|
|
5797
5796
|
if (layerPaintConfString !== layerPaintConfsRef.current[layer.id]) {
|
|
5798
5797
|
for (var paintKey in layer.paint) {
|
|
5799
|
-
mapHook.map.
|
|
5798
|
+
mapHook.map.setPaintProperty(layer.id, paintKey, layer.paint[paintKey]);
|
|
5800
5799
|
}
|
|
5801
5800
|
}
|
|
5802
5801
|
layerPaintConfsRef.current[layer.id] = layerPaintConfString;
|
|
@@ -5804,7 +5803,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5804
5803
|
var layerLayoutConfString = JSON.stringify(layer.layout);
|
|
5805
5804
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[layer.id]) {
|
|
5806
5805
|
for (var layoutKey in layer.layout) {
|
|
5807
|
-
mapHook.map.
|
|
5806
|
+
mapHook.map.setLayoutProperty(layer.id, layoutKey, layer.layout[layoutKey]);
|
|
5808
5807
|
}
|
|
5809
5808
|
}
|
|
5810
5809
|
layerLayoutConfsRef.current[layer.id] = layerLayoutConfString;
|
|
@@ -6690,7 +6689,7 @@ function TemporalControllerPlayer(props) {
|
|
|
6690
6689
|
var _a = React.useState(props.currentVal), currentVal = _a[0], setCurrentVal = _a[1];
|
|
6691
6690
|
var _b = React.useState(props.isPlaying), isPlaying = _b[0], setIsPlaying = _b[1];
|
|
6692
6691
|
var range = props.maxVal - props.minVal;
|
|
6693
|
-
var intervalRef = React.useRef();
|
|
6692
|
+
var intervalRef = React.useRef(null);
|
|
6694
6693
|
var mediaIsMobile = material.useMediaQuery(function (theme) { return theme.breakpoints.down('md'); });
|
|
6695
6694
|
React.useEffect(function () {
|
|
6696
6695
|
return function () {
|
|
@@ -6710,7 +6709,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6710
6709
|
}
|
|
6711
6710
|
intervalRef.current = setInterval(function () {
|
|
6712
6711
|
if (counter >= range) {
|
|
6713
|
-
|
|
6712
|
+
if (intervalRef.current)
|
|
6713
|
+
clearInterval(intervalRef.current);
|
|
6714
6714
|
setIsPlaying(false);
|
|
6715
6715
|
}
|
|
6716
6716
|
else {
|
|
@@ -6728,18 +6728,21 @@ function TemporalControllerPlayer(props) {
|
|
|
6728
6728
|
else {
|
|
6729
6729
|
setIsPlaying(false);
|
|
6730
6730
|
if (isPlaying) {
|
|
6731
|
-
|
|
6731
|
+
if (intervalRef.current)
|
|
6732
|
+
clearInterval(intervalRef.current);
|
|
6732
6733
|
}
|
|
6733
6734
|
}
|
|
6734
6735
|
};
|
|
6735
6736
|
var handleStop = function () {
|
|
6736
|
-
|
|
6737
|
+
if (intervalRef.current)
|
|
6738
|
+
clearInterval(intervalRef.current);
|
|
6737
6739
|
setCurrentVal(props.minVal);
|
|
6738
6740
|
setIsPlaying(false);
|
|
6739
6741
|
};
|
|
6740
6742
|
var handleFastRewind = function () {
|
|
6741
6743
|
if (isPlaying) {
|
|
6742
|
-
|
|
6744
|
+
if (intervalRef.current)
|
|
6745
|
+
clearInterval(intervalRef.current);
|
|
6743
6746
|
setCurrentVal(currentVal - range / 10);
|
|
6744
6747
|
play();
|
|
6745
6748
|
}
|
|
@@ -6749,7 +6752,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6749
6752
|
};
|
|
6750
6753
|
var handleFastForward = function () {
|
|
6751
6754
|
if (isPlaying) {
|
|
6752
|
-
|
|
6755
|
+
if (intervalRef.current)
|
|
6756
|
+
clearInterval(intervalRef.current);
|
|
6753
6757
|
setCurrentVal(currentVal + range / 10);
|
|
6754
6758
|
play();
|
|
6755
6759
|
}
|
|
@@ -6764,7 +6768,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6764
6768
|
}
|
|
6765
6769
|
else {
|
|
6766
6770
|
if (e) {
|
|
6767
|
-
|
|
6771
|
+
if (intervalRef.current)
|
|
6772
|
+
clearInterval(intervalRef.current);
|
|
6768
6773
|
setCurrentVal(newValue);
|
|
6769
6774
|
play();
|
|
6770
6775
|
}
|
|
@@ -6890,13 +6895,14 @@ var MlTemporalController = function (props) {
|
|
|
6890
6895
|
setCurrentVal(props.initialVal);
|
|
6891
6896
|
}
|
|
6892
6897
|
}, []);
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6898
|
+
React.useEffect(function () {
|
|
6899
|
+
if (typeof props.onStateChange === 'function') {
|
|
6900
|
+
props.onStateChange({
|
|
6901
|
+
current: currentVal,
|
|
6902
|
+
paint: paint,
|
|
6903
|
+
});
|
|
6904
|
+
}
|
|
6905
|
+
}, [props.onStateChange]);
|
|
6900
6906
|
// Fit map to bbox
|
|
6901
6907
|
React.useEffect(function () {
|
|
6902
6908
|
var _a;
|
|
@@ -7095,7 +7101,7 @@ var MlSketchTool = function (props) {
|
|
|
7095
7101
|
};
|
|
7096
7102
|
return (React.createElement(React.Fragment, null,
|
|
7097
7103
|
React.createElement(Tooltip, { title: el.name },
|
|
7098
|
-
React.createElement(material.Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7104
|
+
React.createElement(material.Button, { key: el.name, sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7099
7105
|
backgroundColor: stateColor,
|
|
7100
7106
|
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
7101
7107
|
})));
|
|
@@ -7113,7 +7119,12 @@ var MlSketchTool = function (props) {
|
|
|
7113
7119
|
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
7114
7120
|
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
7115
7121
|
var tempFeature = feature[0];
|
|
7116
|
-
tempFeature
|
|
7122
|
+
if (tempFeature && tempFeature.properties) {
|
|
7123
|
+
tempFeature.properties.id = tempFeature.id;
|
|
7124
|
+
}
|
|
7125
|
+
else {
|
|
7126
|
+
console.error('tempFeature or tempFeature.properties is null or undefined');
|
|
7127
|
+
}
|
|
7117
7128
|
_sketchState.activeGeometryIndex = _geometries.length;
|
|
7118
7129
|
_geometries.push(tempFeature);
|
|
7119
7130
|
}
|
|
@@ -7173,7 +7184,7 @@ var MlSketchTool = function (props) {
|
|
|
7173
7184
|
},
|
|
7174
7185
|
fill: {
|
|
7175
7186
|
'fill-color': '#dd9900',
|
|
7176
|
-
'fill-opacity': 0.4
|
|
7187
|
+
'fill-opacity': 0.4,
|
|
7177
7188
|
},
|
|
7178
7189
|
} }))),
|
|
7179
7190
|
sketchState.drawMode === 'simple_select' && (React.createElement(material.Typography, { sx: { fontSize: '0.6em' } },
|
|
@@ -7198,7 +7209,7 @@ var useCameraFollowPath = function (props) {
|
|
|
7198
7209
|
var pitch = React.useRef(props.pitch);
|
|
7199
7210
|
var step = React.useRef(1);
|
|
7200
7211
|
var speed = React.useRef(props.speed);
|
|
7201
|
-
var timeoutId = React.useRef();
|
|
7212
|
+
var timeoutId = React.useRef(null);
|
|
7202
7213
|
var kmPerStep = props.kmPerStep || 0.01;
|
|
7203
7214
|
var routeDistance = turf__namespace.length(props.route);
|
|
7204
7215
|
var stepDuration = props.stepDuration || 70;
|
|
@@ -7540,7 +7551,6 @@ function convertOSM(params) {
|
|
|
7540
7551
|
});
|
|
7541
7552
|
});
|
|
7542
7553
|
}
|
|
7543
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7544
7554
|
var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7545
7555
|
var parsedParams, data;
|
|
7546
7556
|
return __generator(this, function (_a) {
|
|
@@ -7560,7 +7570,6 @@ var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, vo
|
|
|
7560
7570
|
|
|
7561
7571
|
function reduceFeatures(geojson) {
|
|
7562
7572
|
var newFeatures = [];
|
|
7563
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7564
7573
|
geojson.features.forEach(function (e) {
|
|
7565
7574
|
if (!e.features) {
|
|
7566
7575
|
newFeatures.push({
|
|
@@ -7593,6 +7602,7 @@ function convertTopojson(params) {
|
|
|
7593
7602
|
topoJsonData = JSON.parse(rawData);
|
|
7594
7603
|
}
|
|
7595
7604
|
catch (e) {
|
|
7605
|
+
console.error('Error converting topojson', e);
|
|
7596
7606
|
throw 'Invalid TopoJson';
|
|
7597
7607
|
}
|
|
7598
7608
|
// Convert the data
|
|
@@ -7601,15 +7611,16 @@ function convertTopojson(params) {
|
|
|
7601
7611
|
features: [],
|
|
7602
7612
|
};
|
|
7603
7613
|
if (topoJsonData.type === 'Topology' && topoJsonData.objects !== undefined) {
|
|
7614
|
+
var topoJsonDataObjects_1 = topoJsonData.objects;
|
|
7604
7615
|
// add the "fromObject" property in each topojson feature
|
|
7605
7616
|
Object.keys(topoJsonData.objects).map(function (key) {
|
|
7606
|
-
var _a, _b
|
|
7607
|
-
if ((
|
|
7608
|
-
(
|
|
7617
|
+
var _a, _b;
|
|
7618
|
+
if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].type) === 'GeometryCollection') {
|
|
7619
|
+
(_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
7620
|
}
|
|
7610
|
-
else if ((
|
|
7611
|
-
((
|
|
7612
|
-
|
|
7621
|
+
else if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) &&
|
|
7622
|
+
((_b = topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) === null || _b === void 0 ? void 0 : _b.type) !== 'GeometryCollection') {
|
|
7623
|
+
topoJsonDataObjects_1[key].properties = __assign({ fromObject: key }, topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].properties);
|
|
7613
7624
|
}
|
|
7614
7625
|
});
|
|
7615
7626
|
//convert the data into a geoJson object
|
|
@@ -7680,7 +7691,6 @@ function convertXML(params) {
|
|
|
7680
7691
|
});
|
|
7681
7692
|
});
|
|
7682
7693
|
}
|
|
7683
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7684
7694
|
var XMLProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7685
7695
|
var parsedParams, data;
|
|
7686
7696
|
return __generator(this, function (_a) {
|