@mapcomponents/react-maplibre 1.0.10 → 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/CHANGELOG.md +6 -0
- 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 +75 -67
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,15 +3984,15 @@ var MlNavigationTools = function (props) {
|
|
|
3987
3984
|
var zoomIn = useCallback(function () {
|
|
3988
3985
|
if (!mapHook.map)
|
|
3989
3986
|
return;
|
|
3990
|
-
if (mapHook.map.transform.
|
|
3991
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform.
|
|
3987
|
+
if (mapHook.map.transform.zoom + 0.5 <= mapHook.map.transform.maxZoom) {
|
|
3988
|
+
mapHook.map.easeTo({ zoom: mapHook.map.transform.zoom + 0.5 });
|
|
3992
3989
|
}
|
|
3993
3990
|
}, [mapHook.map]);
|
|
3994
3991
|
var zoomOut = useCallback(function () {
|
|
3995
3992
|
if (!mapHook.map)
|
|
3996
3993
|
return;
|
|
3997
|
-
if (mapHook.map.transform.
|
|
3998
|
-
mapHook.map.easeTo({ zoom: mapHook.map.transform.
|
|
3994
|
+
if (mapHook.map.transform.zoom - 0.5 >= mapHook.map.transform.minZoom) {
|
|
3995
|
+
mapHook.map.easeTo({ zoom: mapHook.map.transform.zoom - 0.5 });
|
|
3999
3996
|
}
|
|
4000
3997
|
}, [mapHook.map]);
|
|
4001
3998
|
var adjustPitch = useCallback(function () {
|
|
@@ -4362,12 +4359,12 @@ var MlLayerSwipe = function (props) {
|
|
|
4362
4359
|
document.removeEventListener('mouseup', onMouseUp);
|
|
4363
4360
|
};
|
|
4364
4361
|
function adjustWindowSize() {
|
|
4365
|
-
var clipWidth = mapContext.maps[props.map2Id]
|
|
4362
|
+
var clipWidth = parseFloat(mapContext.maps[props.map2Id]
|
|
4366
4363
|
.getContainer()
|
|
4367
4364
|
.style.clip.split(',')[1]
|
|
4368
|
-
.replace('px', '');
|
|
4365
|
+
.replace('px', ''));
|
|
4369
4366
|
var canvasWidth = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect().width;
|
|
4370
|
-
if (
|
|
4367
|
+
if (clipWidth < canvasWidth) {
|
|
4371
4368
|
var newPosition = parseFloat(((clipWidth / canvasWidth) * 100).toFixed(2));
|
|
4372
4369
|
setSwipeX(newPosition);
|
|
4373
4370
|
}
|
|
@@ -4568,7 +4565,7 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4568
4565
|
});
|
|
4569
4566
|
var initializedRef = useRef(false);
|
|
4570
4567
|
// transition effect variables
|
|
4571
|
-
var oldGeojsonRef = useRef();
|
|
4568
|
+
var oldGeojsonRef = useRef(null);
|
|
4572
4569
|
var transitionInProgressRef = useRef(false);
|
|
4573
4570
|
var transitionTimeoutRef = useRef(undefined);
|
|
4574
4571
|
var currentTransitionStepRef = useRef(false);
|
|
@@ -4598,7 +4595,9 @@ var MlTransitionGeoJsonLayer = function (props) {
|
|
|
4598
4595
|
transitionGeojsonCommonDataRef.current = [];
|
|
4599
4596
|
transitionToGeojson();
|
|
4600
4597
|
}
|
|
4601
|
-
|
|
4598
|
+
if (props.geojson) {
|
|
4599
|
+
oldGeojsonRef.current = props.geojson;
|
|
4600
|
+
}
|
|
4602
4601
|
}, [mapHook.map, transitionToGeojson, props]);
|
|
4603
4602
|
var startTransition = useCallback(function () {
|
|
4604
4603
|
if (props.type === 'line' &&
|
|
@@ -5390,7 +5389,7 @@ var MlShareMapState = function (props) {
|
|
|
5390
5389
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5391
5390
|
var mapContext = useContext(MapContext);
|
|
5392
5391
|
var initializedRef = useRef(false);
|
|
5393
|
-
var mapRef = useRef();
|
|
5392
|
+
var mapRef = useRef(null);
|
|
5394
5393
|
var _a = useState(undefined), map = _a[0], setMap = _a[1];
|
|
5395
5394
|
var layersFromUrlParamsRef = useRef({});
|
|
5396
5395
|
var componentId = useRef((props.idPrefix ? props.idPrefix : 'MlShareMapState-') + v4());
|
|
@@ -5405,7 +5404,7 @@ var MlShareMapState = function (props) {
|
|
|
5405
5404
|
},
|
|
5406
5405
|
});
|
|
5407
5406
|
var allStatesRestoredRef = useRef(false);
|
|
5408
|
-
var layerStatesRestored = useRef();
|
|
5407
|
+
var layerStatesRestored = useRef(null);
|
|
5409
5408
|
var restoredStatesRef = useRef({
|
|
5410
5409
|
viewport: {
|
|
5411
5410
|
center: false,
|
|
@@ -5451,7 +5450,7 @@ var MlShareMapState = function (props) {
|
|
|
5451
5450
|
// check for the existence of map.style before calling getLayer or getSource
|
|
5452
5451
|
if (mapRef.current) {
|
|
5453
5452
|
mapRef.current.cleanup(_componentId);
|
|
5454
|
-
mapRef.current =
|
|
5453
|
+
mapRef.current = null;
|
|
5455
5454
|
}
|
|
5456
5455
|
initializedRef.current = false;
|
|
5457
5456
|
};
|
|
@@ -5489,7 +5488,7 @@ var MlShareMapState = function (props) {
|
|
|
5489
5488
|
if (!((_a = mapState === null || mapState === void 0 ? void 0 : mapState.layers) === null || _a === void 0 ? void 0 : _a.length))
|
|
5490
5489
|
return;
|
|
5491
5490
|
if (typeof layerStatesRestored.current === 'undefined') {
|
|
5492
|
-
layerStatesRestored.current =
|
|
5491
|
+
layerStatesRestored.current = null;
|
|
5493
5492
|
(_b = initialUrlParams === null || initialUrlParams === void 0 ? void 0 : initialUrlParams.layers) === null || _b === void 0 ? void 0 : _b.forEach(function (layer) {
|
|
5494
5493
|
var _a;
|
|
5495
5494
|
if ((_a = layerStatesRestored.current) === null || _a === void 0 ? void 0 : _a[layer.id]) {
|
|
@@ -5603,7 +5602,7 @@ function getElevationData(_geojsonInfo, elevationFactor) {
|
|
|
5603
5602
|
_geojsonInfo.line.geometry.coordinates.forEach(function (coordinate, index) {
|
|
5604
5603
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5605
5604
|
//points.push(point);
|
|
5606
|
-
if (_geojsonInfo.line.geometry.coordinates[index + 1]) {
|
|
5605
|
+
if (_geojsonInfo.line.geometry.coordinates[index + 1] && Array.isArray(coordinate)) {
|
|
5607
5606
|
var wayLength = distance([coordinate[0], coordinate[1]], [
|
|
5608
5607
|
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
5609
5608
|
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
@@ -5772,7 +5771,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5772
5771
|
var layerPaintConfString = JSON.stringify(layer.paint);
|
|
5773
5772
|
if (layerPaintConfString !== layerPaintConfsRef.current[layer.id]) {
|
|
5774
5773
|
for (var paintKey in layer.paint) {
|
|
5775
|
-
mapHook.map.
|
|
5774
|
+
mapHook.map.setPaintProperty(layer.id, paintKey, layer.paint[paintKey]);
|
|
5776
5775
|
}
|
|
5777
5776
|
}
|
|
5778
5777
|
layerPaintConfsRef.current[layer.id] = layerPaintConfString;
|
|
@@ -5780,7 +5779,7 @@ var MlVectorTileLayer = function (props) {
|
|
|
5780
5779
|
var layerLayoutConfString = JSON.stringify(layer.layout);
|
|
5781
5780
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[layer.id]) {
|
|
5782
5781
|
for (var layoutKey in layer.layout) {
|
|
5783
|
-
mapHook.map.
|
|
5782
|
+
mapHook.map.setLayoutProperty(layer.id, layoutKey, layer.layout[layoutKey]);
|
|
5784
5783
|
}
|
|
5785
5784
|
}
|
|
5786
5785
|
layerLayoutConfsRef.current[layer.id] = layerLayoutConfString;
|
|
@@ -6666,7 +6665,7 @@ function TemporalControllerPlayer(props) {
|
|
|
6666
6665
|
var _a = useState(props.currentVal), currentVal = _a[0], setCurrentVal = _a[1];
|
|
6667
6666
|
var _b = useState(props.isPlaying), isPlaying = _b[0], setIsPlaying = _b[1];
|
|
6668
6667
|
var range = props.maxVal - props.minVal;
|
|
6669
|
-
var intervalRef = useRef();
|
|
6668
|
+
var intervalRef = useRef(null);
|
|
6670
6669
|
var mediaIsMobile = useMediaQuery(function (theme) { return theme.breakpoints.down('md'); });
|
|
6671
6670
|
useEffect(function () {
|
|
6672
6671
|
return function () {
|
|
@@ -6686,7 +6685,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6686
6685
|
}
|
|
6687
6686
|
intervalRef.current = setInterval(function () {
|
|
6688
6687
|
if (counter >= range) {
|
|
6689
|
-
|
|
6688
|
+
if (intervalRef.current)
|
|
6689
|
+
clearInterval(intervalRef.current);
|
|
6690
6690
|
setIsPlaying(false);
|
|
6691
6691
|
}
|
|
6692
6692
|
else {
|
|
@@ -6704,18 +6704,21 @@ function TemporalControllerPlayer(props) {
|
|
|
6704
6704
|
else {
|
|
6705
6705
|
setIsPlaying(false);
|
|
6706
6706
|
if (isPlaying) {
|
|
6707
|
-
|
|
6707
|
+
if (intervalRef.current)
|
|
6708
|
+
clearInterval(intervalRef.current);
|
|
6708
6709
|
}
|
|
6709
6710
|
}
|
|
6710
6711
|
};
|
|
6711
6712
|
var handleStop = function () {
|
|
6712
|
-
|
|
6713
|
+
if (intervalRef.current)
|
|
6714
|
+
clearInterval(intervalRef.current);
|
|
6713
6715
|
setCurrentVal(props.minVal);
|
|
6714
6716
|
setIsPlaying(false);
|
|
6715
6717
|
};
|
|
6716
6718
|
var handleFastRewind = function () {
|
|
6717
6719
|
if (isPlaying) {
|
|
6718
|
-
|
|
6720
|
+
if (intervalRef.current)
|
|
6721
|
+
clearInterval(intervalRef.current);
|
|
6719
6722
|
setCurrentVal(currentVal - range / 10);
|
|
6720
6723
|
play();
|
|
6721
6724
|
}
|
|
@@ -6725,7 +6728,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6725
6728
|
};
|
|
6726
6729
|
var handleFastForward = function () {
|
|
6727
6730
|
if (isPlaying) {
|
|
6728
|
-
|
|
6731
|
+
if (intervalRef.current)
|
|
6732
|
+
clearInterval(intervalRef.current);
|
|
6729
6733
|
setCurrentVal(currentVal + range / 10);
|
|
6730
6734
|
play();
|
|
6731
6735
|
}
|
|
@@ -6740,7 +6744,8 @@ function TemporalControllerPlayer(props) {
|
|
|
6740
6744
|
}
|
|
6741
6745
|
else {
|
|
6742
6746
|
if (e) {
|
|
6743
|
-
|
|
6747
|
+
if (intervalRef.current)
|
|
6748
|
+
clearInterval(intervalRef.current);
|
|
6744
6749
|
setCurrentVal(newValue);
|
|
6745
6750
|
play();
|
|
6746
6751
|
}
|
|
@@ -6866,13 +6871,14 @@ var MlTemporalController = function (props) {
|
|
|
6866
6871
|
setCurrentVal(props.initialVal);
|
|
6867
6872
|
}
|
|
6868
6873
|
}, []);
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6874
|
+
useEffect(function () {
|
|
6875
|
+
if (typeof props.onStateChange === 'function') {
|
|
6876
|
+
props.onStateChange({
|
|
6877
|
+
current: currentVal,
|
|
6878
|
+
paint: paint,
|
|
6879
|
+
});
|
|
6880
|
+
}
|
|
6881
|
+
}, [props.onStateChange]);
|
|
6876
6882
|
// Fit map to bbox
|
|
6877
6883
|
useEffect(function () {
|
|
6878
6884
|
var _a;
|
|
@@ -7071,7 +7077,7 @@ var MlSketchTool = function (props) {
|
|
|
7071
7077
|
};
|
|
7072
7078
|
return (React__default.createElement(React__default.Fragment, null,
|
|
7073
7079
|
React__default.createElement(Tooltip$1, { title: el.name },
|
|
7074
|
-
React__default.createElement(Button, { sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7080
|
+
React__default.createElement(Button, { key: el.name, sx: __assign({ color: stateIconColor, backgroundColor: stateColor, '&:hover': {
|
|
7075
7081
|
backgroundColor: stateColor,
|
|
7076
7082
|
} }, buttonStyle), onClick: function () { return buttonClickHandler(el.mode); } }, el.icon))));
|
|
7077
7083
|
})));
|
|
@@ -7089,7 +7095,12 @@ var MlSketchTool = function (props) {
|
|
|
7089
7095
|
var _geometries = __spreadArray([], sketchState.geometries, true);
|
|
7090
7096
|
if (typeof _sketchState.activeGeometryIndex === 'undefined') {
|
|
7091
7097
|
var tempFeature = feature[0];
|
|
7092
|
-
tempFeature
|
|
7098
|
+
if (tempFeature && tempFeature.properties) {
|
|
7099
|
+
tempFeature.properties.id = tempFeature.id;
|
|
7100
|
+
}
|
|
7101
|
+
else {
|
|
7102
|
+
console.error('tempFeature or tempFeature.properties is null or undefined');
|
|
7103
|
+
}
|
|
7093
7104
|
_sketchState.activeGeometryIndex = _geometries.length;
|
|
7094
7105
|
_geometries.push(tempFeature);
|
|
7095
7106
|
}
|
|
@@ -7149,7 +7160,7 @@ var MlSketchTool = function (props) {
|
|
|
7149
7160
|
},
|
|
7150
7161
|
fill: {
|
|
7151
7162
|
'fill-color': '#dd9900',
|
|
7152
|
-
'fill-opacity': 0.4
|
|
7163
|
+
'fill-opacity': 0.4,
|
|
7153
7164
|
},
|
|
7154
7165
|
} }))),
|
|
7155
7166
|
sketchState.drawMode === 'simple_select' && (React__default.createElement(Typography, { sx: { fontSize: '0.6em' } },
|
|
@@ -7174,7 +7185,7 @@ var useCameraFollowPath = function (props) {
|
|
|
7174
7185
|
var pitch = useRef(props.pitch);
|
|
7175
7186
|
var step = useRef(1);
|
|
7176
7187
|
var speed = useRef(props.speed);
|
|
7177
|
-
var timeoutId = useRef();
|
|
7188
|
+
var timeoutId = useRef(null);
|
|
7178
7189
|
var kmPerStep = props.kmPerStep || 0.01;
|
|
7179
7190
|
var routeDistance = turf.length(props.route);
|
|
7180
7191
|
var stepDuration = props.stepDuration || 70;
|
|
@@ -7516,7 +7527,6 @@ function convertOSM(params) {
|
|
|
7516
7527
|
});
|
|
7517
7528
|
});
|
|
7518
7529
|
}
|
|
7519
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7520
7530
|
var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7521
7531
|
var parsedParams, data;
|
|
7522
7532
|
return __generator(this, function (_a) {
|
|
@@ -7536,7 +7546,6 @@ var OSMProtocolHandler = function (params) { return __awaiter(void 0, void 0, vo
|
|
|
7536
7546
|
|
|
7537
7547
|
function reduceFeatures(geojson) {
|
|
7538
7548
|
var newFeatures = [];
|
|
7539
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7540
7549
|
geojson.features.forEach(function (e) {
|
|
7541
7550
|
if (!e.features) {
|
|
7542
7551
|
newFeatures.push({
|
|
@@ -7569,6 +7578,7 @@ function convertTopojson(params) {
|
|
|
7569
7578
|
topoJsonData = JSON.parse(rawData);
|
|
7570
7579
|
}
|
|
7571
7580
|
catch (e) {
|
|
7581
|
+
console.error('Error converting topojson', e);
|
|
7572
7582
|
throw 'Invalid TopoJson';
|
|
7573
7583
|
}
|
|
7574
7584
|
// Convert the data
|
|
@@ -7577,15 +7587,16 @@ function convertTopojson(params) {
|
|
|
7577
7587
|
features: [],
|
|
7578
7588
|
};
|
|
7579
7589
|
if (topoJsonData.type === 'Topology' && topoJsonData.objects !== undefined) {
|
|
7590
|
+
var topoJsonDataObjects_1 = topoJsonData.objects;
|
|
7580
7591
|
// add the "fromObject" property in each topojson feature
|
|
7581
7592
|
Object.keys(topoJsonData.objects).map(function (key) {
|
|
7582
|
-
var _a, _b
|
|
7583
|
-
if ((
|
|
7584
|
-
(
|
|
7593
|
+
var _a, _b;
|
|
7594
|
+
if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].type) === 'GeometryCollection') {
|
|
7595
|
+
(_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
7596
|
}
|
|
7586
|
-
else if ((
|
|
7587
|
-
((
|
|
7588
|
-
|
|
7597
|
+
else if ((topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) &&
|
|
7598
|
+
((_b = topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key]) === null || _b === void 0 ? void 0 : _b.type) !== 'GeometryCollection') {
|
|
7599
|
+
topoJsonDataObjects_1[key].properties = __assign({ fromObject: key }, topoJsonDataObjects_1 === null || topoJsonDataObjects_1 === void 0 ? void 0 : topoJsonDataObjects_1[key].properties);
|
|
7589
7600
|
}
|
|
7590
7601
|
});
|
|
7591
7602
|
//convert the data into a geoJson object
|
|
@@ -7656,7 +7667,6 @@ function convertXML(params) {
|
|
|
7656
7667
|
});
|
|
7657
7668
|
});
|
|
7658
7669
|
}
|
|
7659
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7660
7670
|
var XMLProtocolHandler = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7661
7671
|
var parsedParams, data;
|
|
7662
7672
|
return __generator(this, function (_a) {
|