@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.esm.js
CHANGED
|
@@ -180,7 +180,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
180
180
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
184
183
|
var MapLibreGlWrapper = /** @class */ (function () {
|
|
185
184
|
function MapLibreGlWrapper(props) {
|
|
186
185
|
var _this = this;
|
|
@@ -482,7 +481,6 @@ var MapLibreGlWrapper = /** @class */ (function () {
|
|
|
482
481
|
self.initRegisteredElements(componentId);
|
|
483
482
|
self.registeredElements[componentId].events.push(_arguments);
|
|
484
483
|
}
|
|
485
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
486
484
|
// @ts-ignore
|
|
487
485
|
(_a = self.map).on.apply(_a, _arguments);
|
|
488
486
|
return _this;
|
|
@@ -530,7 +528,6 @@ var MapLibreGlWrapper = /** @class */ (function () {
|
|
|
530
528
|
// cleanup events
|
|
531
529
|
self.registeredElements[componentId].events.forEach(function (item) {
|
|
532
530
|
var _a;
|
|
533
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
534
531
|
// @ts-ignore
|
|
535
532
|
(_a = self.map).off.apply(_a, item);
|
|
536
533
|
});
|
|
@@ -1063,8 +1060,8 @@ var defaultProps$1 = {
|
|
|
1063
1060
|
*/
|
|
1064
1061
|
var MapLibreMap = function (props) {
|
|
1065
1062
|
var _a, _b;
|
|
1066
|
-
var mapRef = useRef();
|
|
1067
|
-
var mapContainer = useRef();
|
|
1063
|
+
var mapRef = useRef(null);
|
|
1064
|
+
var mapContainer = useRef(null);
|
|
1068
1065
|
var mapContext = useContext(MapContext);
|
|
1069
1066
|
var mapIdRef = useRef(props.mapId);
|
|
1070
1067
|
var initializedRef = useRef(false);
|
|
@@ -1078,7 +1075,7 @@ var MapLibreMap = function (props) {
|
|
|
1078
1075
|
if (mapRef.current) {
|
|
1079
1076
|
(_b = (_a = mapRef.current.map) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1080
1077
|
mapRef.current.cancelled = true;
|
|
1081
|
-
mapRef.current =
|
|
1078
|
+
mapRef.current = null;
|
|
1082
1079
|
}
|
|
1083
1080
|
};
|
|
1084
1081
|
}, []);
|
|
@@ -1132,11 +1129,11 @@ function useMapState(props) {
|
|
|
1132
1129
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1133
1130
|
var mapContext = useContext(MapContext);
|
|
1134
1131
|
var initializedRef = useRef(false);
|
|
1135
|
-
var mapRef = useRef();
|
|
1132
|
+
var mapRef = useRef(null);
|
|
1136
1133
|
var _a = useState(), viewport = _a[0], setViewport = _a[1];
|
|
1137
1134
|
var viewportRef = useRef(undefined);
|
|
1138
1135
|
var _b = useState([]), layers = _b[0], setLayers = _b[1];
|
|
1139
|
-
var layersRef = useRef();
|
|
1136
|
+
var layersRef = useRef("");
|
|
1140
1137
|
//const mapRef = useRef(props.map);
|
|
1141
1138
|
var componentId = useRef(v4());
|
|
1142
1139
|
/**
|
|
@@ -1176,7 +1173,7 @@ function useMapState(props) {
|
|
|
1176
1173
|
// cleanup all event listeners
|
|
1177
1174
|
if (mapRef.current) {
|
|
1178
1175
|
mapRef.current.cleanup(_componentId);
|
|
1179
|
-
mapRef.current =
|
|
1176
|
+
mapRef.current = null;
|
|
1180
1177
|
}
|
|
1181
1178
|
initializedRef.current = false;
|
|
1182
1179
|
};
|
|
@@ -1243,7 +1240,7 @@ function useMap(props) {
|
|
|
1243
1240
|
includeBaseLayers: true,
|
|
1244
1241
|
},
|
|
1245
1242
|
});
|
|
1246
|
-
var mapRef = useRef();
|
|
1243
|
+
var mapRef = useRef(null);
|
|
1247
1244
|
var componentId = useRef(v4());
|
|
1248
1245
|
var cleanup = function () {
|
|
1249
1246
|
if (mapRef.current) {
|
|
@@ -1253,13 +1250,13 @@ function useMap(props) {
|
|
|
1253
1250
|
useEffect(function () {
|
|
1254
1251
|
return function () {
|
|
1255
1252
|
cleanup();
|
|
1256
|
-
mapRef.current =
|
|
1253
|
+
mapRef.current = null;
|
|
1257
1254
|
};
|
|
1258
1255
|
}, []);
|
|
1259
1256
|
useEffect(function () {
|
|
1260
1257
|
var _a;
|
|
1261
1258
|
if (mapRef.current && mapRef.current.cancelled === true) {
|
|
1262
|
-
mapRef.current =
|
|
1259
|
+
mapRef.current = null;
|
|
1263
1260
|
setState({ map: undefined, ready: false });
|
|
1264
1261
|
}
|
|
1265
1262
|
if (mapRef.current || !mapContext.mapExists(props === null || props === void 0 ? void 0 : props.mapId))
|
|
@@ -1373,6 +1370,8 @@ var createExport = function (options) {
|
|
|
1373
1370
|
bearing: 0,
|
|
1374
1371
|
pitch: 0,
|
|
1375
1372
|
interactive: false,
|
|
1373
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1374
|
+
// @ts-expect-error
|
|
1376
1375
|
preserveDrawingBuffer: true,
|
|
1377
1376
|
fadeDuration: 0,
|
|
1378
1377
|
attributionControl: false,
|
|
@@ -1583,7 +1582,7 @@ var PdfContextProvider = function (_a) {
|
|
|
1583
1582
|
orientation: 'portrait',
|
|
1584
1583
|
fixedScale: 0,
|
|
1585
1584
|
}), options = _d[0], setOptions = _d[1];
|
|
1586
|
-
var geojsonRef = useRef();
|
|
1585
|
+
var geojsonRef = useRef(null);
|
|
1587
1586
|
var template = useMemo(function () {
|
|
1588
1587
|
if (typeof PdfTemplates[format][quality] !== 'undefined') {
|
|
1589
1588
|
return options.orientation === 'portrait'
|
|
@@ -1646,7 +1645,7 @@ function PdfPreview(props) {
|
|
|
1646
1645
|
var _a;
|
|
1647
1646
|
var mapState = useMapState({ mapId: props.mapId, watch: { layers: false, viewport: true } });
|
|
1648
1647
|
var targetRef = useRef(null);
|
|
1649
|
-
var fixedScaleRef = useRef();
|
|
1648
|
+
var fixedScaleRef = useRef(null);
|
|
1650
1649
|
var moveableRef = useRef(null);
|
|
1651
1650
|
var mapContainerRef = useRef(document.querySelector('.mapContainer'));
|
|
1652
1651
|
//const [transform, setTransform] = useState('translate(452.111px, 15.6148px)');
|
|
@@ -1890,7 +1889,6 @@ function PdfForm(props) {
|
|
|
1890
1889
|
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
1891
1890
|
var pdfContext = useContext(PdfContext);
|
|
1892
1891
|
var mapHook = useMap({
|
|
1893
|
-
// eslint-disable-next-line react/prop-types
|
|
1894
1892
|
mapId: props.mapId,
|
|
1895
1893
|
});
|
|
1896
1894
|
var mapExporter = useExportMap({ mapId: props.mapId });
|
|
@@ -1919,7 +1917,6 @@ function PdfForm(props) {
|
|
|
1919
1917
|
.then(function (res) {
|
|
1920
1918
|
if (typeof props.onCreatePdf === 'function') {
|
|
1921
1919
|
res.formData = new FormData(document.getElementById('createPdfFormID'));
|
|
1922
|
-
console.log('testlog');
|
|
1923
1920
|
props.onCreatePdf(res);
|
|
1924
1921
|
}
|
|
1925
1922
|
setLoading(false);
|
|
@@ -2229,7 +2226,7 @@ function featureEditorStyle() {
|
|
|
2229
2226
|
* GeoJson Feature editor that allows to create or manipulate GeoJson data
|
|
2230
2227
|
*/
|
|
2231
2228
|
var useFeatureEditor = function (props) {
|
|
2232
|
-
var draw = useRef();
|
|
2229
|
+
var draw = useRef(null);
|
|
2233
2230
|
var mapHook = useMap({
|
|
2234
2231
|
mapId: props.mapId,
|
|
2235
2232
|
waitForLayer: props.insertBeforeLayer,
|
|
@@ -3292,7 +3289,7 @@ function LayerPropertyForm$1(_a) {
|
|
|
3292
3289
|
case 'slider':
|
|
3293
3290
|
return (React__default.createElement(React__default.Fragment, { key: key },
|
|
3294
3291
|
label,
|
|
3295
|
-
React__default.createElement(Slider, __assign({}, inputPropsByPropKey$1[key], {
|
|
3292
|
+
React__default.createElement(Slider, __assign({}, inputPropsByPropKey$1[key], { value: paintProps[key], valueLabelDisplay: "auto", onChange: function (_ev, value) {
|
|
3296
3293
|
if (value) {
|
|
3297
3294
|
setPaintProps(function (current) {
|
|
3298
3295
|
var _a;
|
|
@@ -3987,16 +3984,12 @@ var MlNavigationTools = function (props) {
|
|
|
3987
3984
|
var zoomIn = useCallback(function () {
|
|
3988
3985
|
if (!mapHook.map)
|
|
3989
3986
|
return;
|
|
3990
|
-
|
|
3991
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform._zoom + 0.5 });
|
|
3992
|
-
}
|
|
3987
|
+
mapHook.map.easeTo({ zoom: mapHook.map.getZoom() + 0.5 });
|
|
3993
3988
|
}, [mapHook.map]);
|
|
3994
3989
|
var zoomOut = useCallback(function () {
|
|
3995
3990
|
if (!mapHook.map)
|
|
3996
3991
|
return;
|
|
3997
|
-
|
|
3998
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform._zoom - 0.5 });
|
|
3999
|
-
}
|
|
3992
|
+
mapHook.map.easeTo({ zoom: mapHook.map.getZoom() - 0.5 });
|
|
4000
3993
|
}, [mapHook.map]);
|
|
4001
3994
|
var adjustPitch = useCallback(function () {
|
|
4002
3995
|
if (!mapHook.map)
|
|
@@ -4362,12 +4355,12 @@ var MlLayerSwipe = function (props) {
|
|
|
4362
4355
|
document.removeEventListener('mouseup', onMouseUp);
|
|
4363
4356
|
};
|
|
4364
4357
|
function adjustWindowSize() {
|
|
4365
|
-
var clipWidth = mapContext.maps[props.map2Id]
|
|
4358
|
+
var clipWidth = parseFloat(mapContext.maps[props.map2Id]
|
|
4366
4359
|
.getContainer()
|
|
4367
4360
|
.style.clip.split(',')[1]
|
|
4368
|
-
.replace('px', '');
|
|
4361
|
+
.replace('px', ''));
|
|
4369
4362
|
var canvasWidth = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect().width;
|
|
4370
|
-
if (
|
|
4363
|
+
if (clipWidth < canvasWidth) {
|
|
4371
4364
|
var newPosition = parseFloat(((clipWidth / canvasWidth) * 100).toFixed(2));
|
|
4372
4365
|
setSwipeX(newPosition);
|
|
4373
4366
|
}
|
|
@@ -4568,7 +4561,7 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4568
4561
|
});
|
|
4569
4562
|
var initializedRef = useRef(false);
|
|
4570
4563
|
// transition effect variables
|
|
4571
|
-
var oldGeojsonRef = useRef();
|
|
4564
|
+
var oldGeojsonRef = useRef(null);
|
|
4572
4565
|
var transitionInProgressRef = useRef(false);
|
|
4573
4566
|
var transitionTimeoutRef = useRef(undefined);
|
|
4574
4567
|
var currentTransitionStepRef = useRef(false);
|
|
@@ -4598,7 +4591,9 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4598
4591
|
transitionGeojsonCommonDataRef.current = [];
|
|
4599
4592
|
transitionToGeojson();
|
|
4600
4593
|
}
|
|
4601
|
-
|
|
4594
|
+
if (props.geojson) {
|
|
4595
|
+
oldGeojsonRef.current = props.geojson;
|
|
4596
|
+
}
|
|
4602
4597
|
}, [mapHook.map, transitionToGeojson, props]);
|
|
4603
4598
|
var startTransition = useCallback(function () {
|
|
4604
4599
|
if (props.type === 'line' &&
|
|
@@ -5390,7 +5385,7 @@ var MlShareMapState = function (props) {
|
|
|
5390
5385
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5391
5386
|
var mapContext = useContext(MapContext);
|
|
5392
5387
|
var initializedRef = useRef(false);
|
|
5393
|
-
var mapRef = useRef();
|
|
5388
|
+
var mapRef = useRef(null);
|
|
5394
5389
|
var _a = useState(undefined), map = _a[0], setMap = _a[1];
|
|
5395
5390
|
var layersFromUrlParamsRef = useRef({});
|
|
5396
5391
|
var componentId = useRef((props.idPrefix ? props.idPrefix : 'MlShareMapState-') + v4());
|
|
@@ -5405,7 +5400,7 @@ var MlShareMapState = function (props) {
|
|
|
5405
5400
|
},
|
|
5406
5401
|
});
|
|
5407
5402
|
var allStatesRestoredRef = useRef(false);
|
|
5408
|
-
var layerStatesRestored = useRef();
|
|
5403
|
+
var layerStatesRestored = useRef(null);
|
|
5409
5404
|
var restoredStatesRef = useRef({
|
|
5410
5405
|
viewport: {
|
|
5411
5406
|
center: false,
|
|
@@ -5451,7 +5446,7 @@ var MlShareMapState = function (props) {
|
|
|
5451
5446
|
// check for the existence of map.style before calling getLayer or getSource
|
|
5452
5447
|
if (mapRef.current) {
|
|
5453
5448
|
mapRef.current.cleanup(_componentId);
|
|
5454
|
-
mapRef.current =
|
|
5449
|
+
mapRef.current = null;
|
|
5455
5450
|
}
|
|
5456
5451
|
initializedRef.current = false;
|
|
5457
5452
|
};
|
|
@@ -5489,7 +5484,7 @@ var MlShareMapState = function (props) {
|
|
|
5489
5484
|
if (!((_a = mapState === null || mapState === void 0 ? void 0 : mapState.layers) === null || _a === void 0 ? void 0 : _a.length))
|
|
5490
5485
|
return;
|
|
5491
5486
|
if (typeof layerStatesRestored.current === 'undefined') {
|
|
5492
|
-
layerStatesRestored.current =
|
|
5487
|
+
layerStatesRestored.current = null;
|
|
5493
5488
|
(_b = initialUrlParams === null || initialUrlParams === void 0 ? void 0 : initialUrlParams.layers) === null || _b === void 0 ? void 0 : _b.forEach(function (layer) {
|
|
5494
5489
|
var _a;
|
|
5495
5490
|
if ((_a = layerStatesRestored.current) === null || _a === void 0 ? void 0 : _a[layer.id]) {
|
|
@@ -5603,7 +5598,7 @@ function getElevationData(_geojsonInfo, elevationFactor) {
|
|
|
5603
5598
|
_geojsonInfo.line.geometry.coordinates.forEach(function (coordinate, index) {
|
|
5604
5599
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5605
5600
|
//points.push(point);
|
|
5606
|
-
if (_geojsonInfo.line.geometry.coordinates[index + 1]) {
|
|
5601
|
+
if (_geojsonInfo.line.geometry.coordinates[index + 1] && Array.isArray(coordinate)) {
|
|
5607
5602
|
var wayLength = distance([coordinate[0], coordinate[1]], [
|
|
5608
5603
|
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
5609
5604
|
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
@@ -5772,7 +5767,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5772
5767
|
var layerPaintConfString = JSON.stringify(layer.paint);
|
|
5773
5768
|
if (layerPaintConfString !== layerPaintConfsRef.current[layer.id]) {
|
|
5774
5769
|
for (var paintKey in layer.paint) {
|
|
5775
|
-
mapHook.map.
|
|
5770
|
+
mapHook.map.setPaintProperty(layer.id, paintKey, layer.paint[paintKey]);
|
|
5776
5771
|
}
|
|
5777
5772
|
}
|
|
5778
5773
|
layerPaintConfsRef.current[layer.id] = layerPaintConfString;
|
|
@@ -5780,7 +5775,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5780
5775
|
var layerLayoutConfString = JSON.stringify(layer.layout);
|
|
5781
5776
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[layer.id]) {
|
|
5782
5777
|
for (var layoutKey in layer.layout) {
|
|
5783
|
-
mapHook.map.
|
|
5778
|
+
mapHook.map.setLayoutProperty(layer.id, layoutKey, layer.layout[layoutKey]);
|
|
5784
5779
|
}
|
|
5785
5780
|
}
|
|
5786
5781
|
layerLayoutConfsRef.current[layer.id] = layerLayoutConfString;
|
|
@@ -6666,7 +6661,7 @@ function TemporalControllerPlayer(props) {
|
|
|
6666
6661
|
var _a = useState(props.currentVal), currentVal = _a[0], setCurrentVal = _a[1];
|
|
6667
6662
|
var _b = useState(props.isPlaying), isPlaying = _b[0], setIsPlaying = _b[1];
|
|
6668
6663
|
var range = props.maxVal - props.minVal;
|
|
6669
|
-
var intervalRef = useRef();
|
|
6664
|
+
var intervalRef = useRef(null);
|
|
6670
6665
|
var mediaIsMobile = useMediaQuery(function (theme) { return theme.breakpoints.down('md'); });
|
|
6671
6666
|
useEffect(function () {
|
|
6672
6667
|
return function () {
|
|
@@ -6686,7 +6681,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6686
6681
|
}
|
|
6687
6682
|
intervalRef.current = setInterval(function () {
|
|
6688
6683
|
if (counter >= range) {
|
|
6689
|
-
|
|
6684
|
+
if (intervalRef.current)
|
|
6685
|
+
clearInterval(intervalRef.current);
|
|
6690
6686
|
setIsPlaying(false);
|
|
6691
6687
|
}
|
|
6692
6688
|
else {
|
|
@@ -6704,18 +6700,21 @@ function TemporalControllerPlayer(props) {
|
|
|
6704
6700
|
else {
|
|
6705
6701
|
setIsPlaying(false);
|
|
6706
6702
|
if (isPlaying) {
|
|
6707
|
-
|
|
6703
|
+
if (intervalRef.current)
|
|
6704
|
+
clearInterval(intervalRef.current);
|
|
6708
6705
|
}
|
|
6709
6706
|
}
|
|
6710
6707
|
};
|
|
6711
6708
|
var handleStop = function () {
|
|
6712
|
-
|
|
6709
|
+
if (intervalRef.current)
|
|
6710
|
+
clearInterval(intervalRef.current);
|
|
6713
6711
|
setCurrentVal(props.minVal);
|
|
6714
6712
|
setIsPlaying(false);
|
|
6715
6713
|
};
|
|
6716
6714
|
var handleFastRewind = function () {
|
|
6717
6715
|
if (isPlaying) {
|
|
6718
|
-
|
|
6716
|
+
if (intervalRef.current)
|
|
6717
|
+
clearInterval(intervalRef.current);
|
|
6719
6718
|
setCurrentVal(currentVal - range / 10);
|
|
6720
6719
|
play();
|
|
6721
6720
|
}
|
|
@@ -6725,7 +6724,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6725
6724
|
};
|
|
6726
6725
|
var handleFastForward = function () {
|
|
6727
6726
|
if (isPlaying) {
|
|
6728
|
-
|
|
6727
|
+
if (intervalRef.current)
|
|
6728
|
+
clearInterval(intervalRef.current);
|
|
6729
6729
|
setCurrentVal(currentVal + range / 10);
|
|
6730
6730
|
play();
|
|
6731
6731
|
}
|
|
@@ -6740,7 +6740,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6740
6740
|
}
|
|
6741
6741
|
else {
|
|
6742
6742
|
if (e) {
|
|
6743
|
-
|
|
6743
|
+
if (intervalRef.current)
|
|
6744
|
+
clearInterval(intervalRef.current);
|
|
6744
6745
|
setCurrentVal(newValue);
|
|
6745
6746
|
play();
|
|
6746
6747
|
}
|
|
@@ -6866,13 +6867,14 @@ var MlTemporalController = function (props) {
|
|
|
6866
6867
|
setCurrentVal(props.initialVal);
|
|
6867
6868
|
}
|
|
6868
6869
|
}, []);
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6870
|
+
useEffect(function () {
|
|
6871
|
+
if (typeof props.onStateChange === 'function') {
|
|
6872
|
+
props.onStateChange({
|
|
6873
|
+
current: currentVal,
|
|
6874
|
+
paint: paint,
|
|
6875
|
+
});
|
|
6876
|
+
}
|
|
6877
|
+
}, [props.onStateChange]);
|
|
6876
6878
|
// Fit map to bbox
|
|
6877
6879
|
useEffect(function () {
|
|
6878
6880
|
var _a;
|
|
@@ -7071,7 +7073,7 @@ var MlSketchTool = function (props) {
|
|
|
7071
7073
|
};
|
|
7072
7074
|
return (React__default.createElement(React__default.Fragment, null,
|
|
7073
7075
|
React__default.createElement(Tooltip$1, { title: el.name },
|
|
7074
|
-
React__default.createElement(Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7076
|
+
React__default.createElement(Button, { key: el.name, sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7075
7077
|
backgroundColor: stateColor,
|
|
7076
7078
|
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
7077
7079
|
})));
|
|
@@ -7089,7 +7091,12 @@ var MlSketchTool = function (props) {
|
|
|
7089
7091
|
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
7090
7092
|
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
7091
7093
|
var tempFeature = feature[0];
|
|
7092
|
-
tempFeature
|
|
7094
|
+
if (tempFeature && tempFeature.properties) {
|
|
7095
|
+
tempFeature.properties.id = tempFeature.id;
|
|
7096
|
+
}
|
|
7097
|
+
else {
|
|
7098
|
+
console.error('tempFeature or tempFeature.properties is null or undefined');
|
|
7099
|
+
}
|
|
7093
7100
|
_sketchState.activeGeometryIndex = _geometries.length;
|
|
7094
7101
|
_geometries.push(tempFeature);
|
|
7095
7102
|
}
|
|
@@ -7149,7 +7156,7 @@ var MlSketchTool = function (props) {
|
|
|
7149
7156
|
},
|
|
7150
7157
|
fill: {
|
|
7151
7158
|
'fill-color': '#dd9900',
|
|
7152
|
-
'fill-opacity': 0.4
|
|
7159
|
+
'fill-opacity': 0.4,
|
|
7153
7160
|
},
|
|
7154
7161
|
} }))),
|
|
7155
7162
|
sketchState.drawMode === 'simple_select' && (React__default.createElement(Typography, { sx: { fontSize: '0.6em' } },
|
|
@@ -7174,7 +7181,7 @@ var useCameraFollowPath = function (props) {
|
|
|
7174
7181
|
var pitch = useRef(props.pitch);
|
|
7175
7182
|
var step = useRef(1);
|
|
7176
7183
|
var speed = useRef(props.speed);
|
|
7177
|
-
var timeoutId = useRef();
|
|
7184
|
+
var timeoutId = useRef(null);
|
|
7178
7185
|
var kmPerStep = props.kmPerStep || 0.01;
|
|
7179
7186
|
var routeDistance = turf.length(props.route);
|
|
7180
7187
|
var stepDuration = props.stepDuration || 70;
|
|
@@ -7516,7 +7523,6 @@ function convertOSM(params) {
|
|
|
7516
7523
|
});
|
|
7517
7524
|
});
|
|
7518
7525
|
}
|
|
7519
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7520
7526
|
var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7521
7527
|
var parsedParams, data;
|
|
7522
7528
|
return __generator(this, function (_a) {
|
|
@@ -7536,7 +7542,6 @@ var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, vo
|
|
|
7536
7542
|
|
|
7537
7543
|
function reduceFeatures(geojson) {
|
|
7538
7544
|
var newFeatures = [];
|
|
7539
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7540
7545
|
geojson.features.forEach(function (e) {
|
|
7541
7546
|
if (!e.features) {
|
|
7542
7547
|
newFeatures.push({
|
|
@@ -7569,6 +7574,7 @@ function convertTopojson(params) {
|
|
|
7569
7574
|
topoJsonData = JSON.parse(rawData);
|
|
7570
7575
|
}
|
|
7571
7576
|
catch (e) {
|
|
7577
|
+
console.error('Error converting topojson', e);
|
|
7572
7578
|
throw 'Invalid TopoJson';
|
|
7573
7579
|
}
|
|
7574
7580
|
// Convert the data
|
|
@@ -7577,15 +7583,16 @@ function convertTopojson(params) {
|
|
|
7577
7583
|
features: [],
|
|
7578
7584
|
};
|
|
7579
7585
|
if (topoJsonData.type === 'Topology' && topoJsonData.objects !== undefined) {
|
|
7586
|
+
var topoJsonDataObjects_1 = topoJsonData.objects;
|
|
7580
7587
|
// add the "fromObject" property in each topojson feature
|
|
7581
7588
|
Object.keys(topoJsonData.objects).map(function (key) {
|
|
7582
|
-
var _a, _b
|
|
7583
|
-
if ((
|
|
7584
|
-
(
|
|
7589
|
+
var _a, _b;
|
|
7590
|
+
if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].type) === 'GeometryCollection') {
|
|
7591
|
+
(_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)); });
|
|
7585
7592
|
}
|
|
7586
|
-
else if ((
|
|
7587
|
-
((
|
|
7588
|
-
|
|
7593
|
+
else if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) &&
|
|
7594
|
+
((_b = topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) === null || _b === void 0 ? void 0 : _b.type) !== 'GeometryCollection') {
|
|
7595
|
+
topoJsonDataObjects_1[key].properties = __assign({ fromObject: key }, topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].properties);
|
|
7589
7596
|
}
|
|
7590
7597
|
});
|
|
7591
7598
|
//convert the data into a geoJson object
|
|
@@ -7656,7 +7663,6 @@ function convertXML(params) {
|
|
|
7656
7663
|
});
|
|
7657
7664
|
});
|
|
7658
7665
|
}
|
|
7659
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7660
7666
|
var XMLProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7661
7667
|
var parsedParams, data;
|
|
7662
7668
|
return __generator(this, function (_a) {
|