@mapcomponents/react-maplibre 0.1.10 → 0.1.14
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/.github/ISSUE_TEMPLATE/bug_report.md +2 -2
- package/.github/ISSUE_TEMPLATE/feature_request.md +3 -3
- package/.github/workflows/node_version_test.yml +25 -0
- package/.github/workflows/storybook.yml +6 -3
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -7
- package/coverage/clover.xml +748 -625
- package/coverage/coverage-final.json +19 -14
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +170 -104
- package/coverage/lcov-report/sorter.js +26 -0
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +99 -48
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +27 -21
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +73 -61
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +56 -71
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +32 -26
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +91 -31
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/MlImageMarkerLayer.js.html +26 -23
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +26 -20
- package/coverage/lcov-report/{components → src/components}/MlLayer/MlLayer.js.html +37 -31
- package/coverage/lcov-report/{components → src/components}/MlLayer/index.html +33 -27
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +48 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +45 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +31 -25
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +18 -12
- package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +55 -37
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +23 -17
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +37 -55
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +20 -14
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +21 -15
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +38 -20
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +23 -17
- package/coverage/lcov-report/{hooks → src/hooks}/index.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useMap.js.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +25 -19
- package/coverage/lcov-report/src/i18n.js.html +167 -0
- package/coverage/lcov-report/src/index.html +117 -0
- package/coverage/lcov-report/src/translations/english.js.html +95 -0
- package/coverage/lcov-report/src/translations/german.js.html +95 -0
- package/coverage/lcov-report/src/translations/index.html +132 -0
- package/coverage/lcov.info +1278 -1010
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +276 -90
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -1
- package/public/assets/dop.png +0 -0
- package/public/assets/historic.png +0 -0
- package/public/assets/osm.png +0 -0
- package/public/thumbnails/MlFollowGps.png +0 -0
- package/public/thumbnails/MlThreeJsLayer.png +0 -0
- package/rollup.config.js +7 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +58 -73
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +46 -31
- package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
- package/src/components/MlFollowGps/assets/marker.png +0 -0
- package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
- package/src/components/MlGPXViewer/gpxConverter.js +22 -29
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +27 -9
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlGeoJsonLayer/util/transitionFunctions.js +19 -12
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +3 -4
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +2 -2
- package/src/components/MlLayer/MlLayer.test.js +12 -10
- package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
- package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
- package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
- package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
- package/src/components/MlMarker/MlMarker.js +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.js +26 -22
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +3 -3
- package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
- package/src/decorators/EmptyMapContextDecorator.js +11 -6
- package/src/decorators/MapContext3DDecorator.js +25 -20
- package/src/decorators/MapContextDashboardDecorator.js +7 -7
- package/src/decorators/MapContextDecorator.js +7 -8
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -9
- package/src/decorators/MultiMapContextDecorator.js +2 -6
- package/src/hooks/useMapState.stories.js +7 -2
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/index.js +1 -0
- package/src/translations/english.js +4 -0
- package/src/translations/german.js +4 -0
- package/src/ui_components/ImageLoader.js +73 -0
- package/src/ui_components/Sidebar.js +76 -22
- package/src/ui_components/TopToolbar.js +18 -18
package/dist/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import Button from '@mui/material/Button';
|
|
|
8
8
|
import maplibregl$1, { Popup } from 'maplibre-gl';
|
|
9
9
|
import jsPDF from 'jspdf';
|
|
10
10
|
import PrinterIcon from '@mui/icons-material/Print';
|
|
11
|
-
import { lineString, length, lineChunk, point, bbox } from '@turf/turf';
|
|
11
|
+
import { lineString, length, lineChunk, point, bbox, lineOffset, distance } from '@turf/turf';
|
|
12
12
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
13
13
|
import ControlPointIcon from '@mui/icons-material/ControlPoint';
|
|
14
14
|
import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
|
|
@@ -16,6 +16,7 @@ import GpsFixedIcon from '@mui/icons-material/GpsFixed';
|
|
|
16
16
|
import _styled from '@emotion/styled/base';
|
|
17
17
|
import { css } from '@emotion/css';
|
|
18
18
|
import RoomIcon from '@mui/icons-material/Room';
|
|
19
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
19
20
|
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
20
21
|
import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
21
22
|
import Point from '@mapbox/point-geometry';
|
|
@@ -30,6 +31,7 @@ import FileCopy from '@mui/icons-material/FileCopy';
|
|
|
30
31
|
import List from '@mui/material/List';
|
|
31
32
|
import ListItem from '@mui/material/ListItem';
|
|
32
33
|
import ListItemText from '@mui/material/ListItemText';
|
|
34
|
+
import { lineString as lineString$1, polygon } from '@turf/helpers';
|
|
33
35
|
|
|
34
36
|
function ownKeys(object, enumerableOnly) {
|
|
35
37
|
var keys = Object.keys(object);
|
|
@@ -287,7 +289,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
287
289
|
on: function on(eventName, handler, options, componentId) {
|
|
288
290
|
if (!self.eventHandlers[eventName]) return;
|
|
289
291
|
|
|
290
|
-
if (typeof options ===
|
|
292
|
+
if (typeof options === "string") {
|
|
291
293
|
componentId = options;
|
|
292
294
|
options = {};
|
|
293
295
|
}
|
|
@@ -428,7 +430,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
428
430
|
*/
|
|
429
431
|
oldViewportStateString: "{}",
|
|
430
432
|
getViewport: function getViewport() {
|
|
431
|
-
return typeof self.map.getCenter ===
|
|
433
|
+
return typeof self.map.getCenter === "function" ? {
|
|
432
434
|
center: function (_ref) {
|
|
433
435
|
var lng = _ref.lng,
|
|
434
436
|
lat = _ref.lat,
|
|
@@ -444,24 +446,8 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
444
446
|
pitch: self.map.getPitch()
|
|
445
447
|
} : {};
|
|
446
448
|
},
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
refreshViewport: function refreshViewport(force) {
|
|
450
|
-
if (self.wrapper.viewportRefreshEnabled || force) {
|
|
451
|
-
self.wrapper.viewportRefreshEnabled = false;
|
|
452
|
-
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
453
|
-
self.wrapper.viewportStateString = JSON.stringify(self.wrapper.viewportState);
|
|
454
|
-
setTimeout(function () {
|
|
455
|
-
self.wrapper.viewportRefreshEnabled = true;
|
|
456
|
-
|
|
457
|
-
if (self.wrapper.viewportRefreshWaiting) {
|
|
458
|
-
self.wrapper.viewportRefreshWaiting = false;
|
|
459
|
-
self.wrapper.refreshViewport();
|
|
460
|
-
}
|
|
461
|
-
}, 50);
|
|
462
|
-
} else {
|
|
463
|
-
self.wrapper.viewportRefreshWaiting = true;
|
|
464
|
-
}
|
|
449
|
+
refreshViewport: function refreshViewport() {
|
|
450
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
465
451
|
}
|
|
466
452
|
};
|
|
467
453
|
/**
|
|
@@ -738,7 +724,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
738
724
|
if (response.ok) {
|
|
739
725
|
return response.json();
|
|
740
726
|
} else {
|
|
741
|
-
throw new Error(
|
|
727
|
+
throw new Error("error loading map style.json");
|
|
742
728
|
}
|
|
743
729
|
}).then(function (styleJson) {
|
|
744
730
|
styleJson.layers.forEach(function (item) {
|
|
@@ -757,15 +743,11 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
757
743
|
case 3:
|
|
758
744
|
self.map = new maplibregl.Map(props.mapOptions);
|
|
759
745
|
self.addNativeMaplibreFunctionsAndProps();
|
|
760
|
-
self.wrapper.refreshViewport(
|
|
746
|
+
self.wrapper.refreshViewport();
|
|
761
747
|
self.wrapper.fire("viewportchange");
|
|
762
748
|
self.map.on("move", function () {
|
|
763
|
-
self.wrapper.
|
|
764
|
-
|
|
765
|
-
if (self.wrapper.viewportStateString !== self.wrapper.oldViewportStateString) {
|
|
766
|
-
self.wrapper.oldViewportStateString = self.wrapper.viewportStateString;
|
|
767
|
-
self.wrapper.fire("viewportchange");
|
|
768
|
-
}
|
|
749
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
750
|
+
self.wrapper.fire("viewportchange");
|
|
769
751
|
});
|
|
770
752
|
self.map.on("data", function () {
|
|
771
753
|
self.wrapper.refreshLayerState();
|
|
@@ -1244,18 +1226,25 @@ MlCreatePdfButton.propTypes = {
|
|
|
1244
1226
|
mapId: PropTypes.string
|
|
1245
1227
|
};
|
|
1246
1228
|
|
|
1247
|
-
var _showNextTransitionSegment = function _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep) {
|
|
1229
|
+
var _showNextTransitionSegment = function _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef) {
|
|
1248
1230
|
var _arguments = arguments;
|
|
1249
1231
|
|
|
1250
1232
|
if (typeof map.getSource(layerId) === "undefined" || !transitionInProgressRef.current) {
|
|
1251
|
-
setTimeout(function () {
|
|
1233
|
+
transitionTimeoutRef.current = setTimeout(function () {
|
|
1252
1234
|
return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
|
|
1253
1235
|
}, msPerStep);
|
|
1254
1236
|
return;
|
|
1255
1237
|
}
|
|
1256
1238
|
|
|
1257
1239
|
if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
|
|
1240
|
+
var _map$getSource;
|
|
1241
|
+
|
|
1258
1242
|
var newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString([].concat(_toConsumableArray(transitionGeojsonCommonDataRef.current), _toConsumableArray(transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates)));
|
|
1243
|
+
|
|
1244
|
+
if (!(map !== null && map !== void 0 && (_map$getSource = map.getSource) !== null && _map$getSource !== void 0 && _map$getSource.call(map, layerId))) {
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1259
1248
|
map.getSource(layerId).setData(newData);
|
|
1260
1249
|
|
|
1261
1250
|
if (typeof props.onTransitionFrame === "function") {
|
|
@@ -1265,7 +1254,7 @@ var _showNextTransitionSegment = function _showNextTransitionSegment(props, laye
|
|
|
1265
1254
|
currentTransitionStepRef.current++;
|
|
1266
1255
|
|
|
1267
1256
|
if (transitionInProgressRef.current && currentTransitionStepRef.current < transitionGeojsonDataRef.current.length) {
|
|
1268
|
-
setTimeout(function () {
|
|
1257
|
+
transitionTimeoutRef.current = setTimeout(function () {
|
|
1269
1258
|
return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
|
|
1270
1259
|
}, msPerStep);
|
|
1271
1260
|
} else {
|
|
@@ -1278,7 +1267,7 @@ var _showNextTransitionSegment = function _showNextTransitionSegment(props, laye
|
|
|
1278
1267
|
}
|
|
1279
1268
|
};
|
|
1280
1269
|
|
|
1281
|
-
var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, map, layerId) {
|
|
1270
|
+
var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, map, layerId, transitionTimeoutRef) {
|
|
1282
1271
|
// create the transition geojson between oldGeojsonRef.current and props.geojson
|
|
1283
1272
|
// create a geojson that contains no common point between the two line features
|
|
1284
1273
|
var transitionCoordinatesShort = [];
|
|
@@ -1361,11 +1350,11 @@ var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, tran
|
|
|
1361
1350
|
|
|
1362
1351
|
tmpLinestring = tmpChunks.features[1];
|
|
1363
1352
|
|
|
1364
|
-
for (i =
|
|
1353
|
+
for (i = 0; i < srcTransitionSteps; i++) {
|
|
1365
1354
|
transitionGeojsonDataRef.current.push(tmpLinestring);
|
|
1366
1355
|
|
|
1367
|
-
if (typeof tmpChunks.features[i
|
|
1368
|
-
tmpLinestring = lineString([].concat(_toConsumableArray(tmpLinestring.geometry.coordinates), _toConsumableArray(tmpChunks.features[i
|
|
1356
|
+
if (typeof tmpChunks.features[i] !== "undefined") {
|
|
1357
|
+
tmpLinestring = lineString([].concat(_toConsumableArray(tmpLinestring.geometry.coordinates), _toConsumableArray(tmpChunks.features[i].geometry.coordinates)));
|
|
1369
1358
|
} else {
|
|
1370
1359
|
transitionGeojsonDataRef.current.push(tmpLinestring);
|
|
1371
1360
|
break;
|
|
@@ -1380,11 +1369,11 @@ var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, tran
|
|
|
1380
1369
|
|
|
1381
1370
|
tmpLinestring = tmpChunks.features[1];
|
|
1382
1371
|
|
|
1383
|
-
for (i =
|
|
1372
|
+
for (i = 0; i < targetTransitionSteps; i++) {
|
|
1384
1373
|
transitionGeojsonDataRef.current.push(tmpLinestring);
|
|
1385
1374
|
|
|
1386
|
-
if (typeof tmpChunks.features[i
|
|
1387
|
-
tmpLinestring = lineString([].concat(_toConsumableArray(tmpLinestring.geometry.coordinates), _toConsumableArray(tmpChunks.features[i
|
|
1375
|
+
if (typeof tmpChunks.features[i] !== "undefined") {
|
|
1376
|
+
tmpLinestring = lineString([].concat(_toConsumableArray(tmpLinestring.geometry.coordinates), _toConsumableArray(tmpChunks.features[i].geometry.coordinates)));
|
|
1388
1377
|
} else {
|
|
1389
1378
|
transitionGeojsonDataRef.current.push(tmpLinestring);
|
|
1390
1379
|
break;
|
|
@@ -1395,8 +1384,8 @@ var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, tran
|
|
|
1395
1384
|
transitionGeojsonDataRef.current.push(props.geojson);
|
|
1396
1385
|
currentTransitionStepRef.current = 1;
|
|
1397
1386
|
transitionInProgressRef.current = true;
|
|
1398
|
-
setTimeout(function () {
|
|
1399
|
-
return _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep);
|
|
1387
|
+
transitionTimeoutRef.current = setTimeout(function () {
|
|
1388
|
+
return _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef);
|
|
1400
1389
|
}, msPerStep);
|
|
1401
1390
|
};
|
|
1402
1391
|
|
|
@@ -1414,6 +1403,7 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1414
1403
|
var mapRef = useRef(null);
|
|
1415
1404
|
var initializedRef = useRef(false);
|
|
1416
1405
|
var transitionInProgressRef = useRef(false);
|
|
1406
|
+
var transitionTimeoutRef = useRef(undefined);
|
|
1417
1407
|
var currentTransitionStepRef = useRef(false);
|
|
1418
1408
|
var transitionGeojsonDataRef = useRef([]);
|
|
1419
1409
|
var transitionGeojsonCommonDataRef = useRef([]);
|
|
@@ -1423,6 +1413,10 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1423
1413
|
var _componentId = componentId.current;
|
|
1424
1414
|
return function () {
|
|
1425
1415
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
1416
|
+
if (transitionTimeoutRef.current) {
|
|
1417
|
+
clearTimeout(transitionTimeoutRef.current);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1426
1420
|
if (mapRef.current) {
|
|
1427
1421
|
mapRef.current.cleanup(_componentId);
|
|
1428
1422
|
mapRef.current = null;
|
|
@@ -1430,15 +1424,21 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1430
1424
|
};
|
|
1431
1425
|
}, []);
|
|
1432
1426
|
useEffect(function () {
|
|
1433
|
-
if (!mapRef.current || !initializedRef.current) return;
|
|
1434
|
-
|
|
1427
|
+
if (!mapRef.current || !initializedRef.current) return;
|
|
1428
|
+
|
|
1429
|
+
for (var key in props.layout) {
|
|
1430
|
+
mapContext.getMap(props.mapId).setLayoutProperty(layerId.current, key, props.layout[key]);
|
|
1431
|
+
}
|
|
1432
|
+
}, [props.layout, mapContext, props.mapId]);
|
|
1433
|
+
useEffect(function () {
|
|
1434
|
+
if (!mapRef.current || !initializedRef.current) return;
|
|
1435
1435
|
|
|
1436
1436
|
for (var key in props.paint) {
|
|
1437
|
-
mapContext.getMap(props.mapId).setPaintProperty(
|
|
1437
|
+
mapContext.getMap(props.mapId).setPaintProperty(layerId.current, key, props.paint[key]);
|
|
1438
1438
|
}
|
|
1439
1439
|
}, [props.paint, mapContext, props.mapId]);
|
|
1440
1440
|
var transitionToGeojson = useCallback(function (newGeojson) {
|
|
1441
|
-
_transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapRef.current, componentId.current);
|
|
1441
|
+
_transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapRef.current, componentId.current, transitionTimeoutRef);
|
|
1442
1442
|
}, [props]);
|
|
1443
1443
|
useEffect(function () {
|
|
1444
1444
|
var _mapRef$current, _mapRef$current$getSo;
|
|
@@ -1482,7 +1482,8 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1482
1482
|
paint: props.paint || {
|
|
1483
1483
|
"line-color": "rgb(100,200,100)",
|
|
1484
1484
|
"line-width": 10
|
|
1485
|
-
}
|
|
1485
|
+
},
|
|
1486
|
+
layout: props.layout || {}
|
|
1486
1487
|
}, props.insertBeforeLayer, componentId.current);
|
|
1487
1488
|
|
|
1488
1489
|
if (typeof props.onHover !== "undefined") {
|
|
@@ -1499,9 +1500,7 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1499
1500
|
|
|
1500
1501
|
if (props.type === "line" && typeof props.transitionTime !== "undefined" && typeof props.geojson.geometry !== "undefined") {
|
|
1501
1502
|
transitionToGeojson(props.geojson);
|
|
1502
|
-
|
|
1503
|
-
oldGeojsonRef.current = props.geojson;
|
|
1504
|
-
}, props.transitionTime / 2);
|
|
1503
|
+
oldGeojsonRef.current = props.geojson;
|
|
1505
1504
|
}
|
|
1506
1505
|
}
|
|
1507
1506
|
}, [mapContext.mapIds, mapContext, props, transitionToGeojson]);
|
|
@@ -1521,8 +1520,17 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1521
1520
|
type: PropTypes.string,
|
|
1522
1521
|
|
|
1523
1522
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
* Possible
|
|
1523
|
+
* Layout property object, that is passed to the addLayer call.
|
|
1524
|
+
* Possible props depend on the layer type.
|
|
1525
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
1526
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
1527
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
1528
|
+
*/
|
|
1529
|
+
layout: PropTypes.object,
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Paint property object, that is passed to the addLayer call.
|
|
1533
|
+
* Possible props depend on the layer type.
|
|
1526
1534
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
1527
1535
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
1528
1536
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
@@ -1577,12 +1585,12 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1577
1585
|
var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
1578
1586
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1579
1587
|
var mapRef = useRef(null);
|
|
1580
|
-
var componentId = useRef((props.idPrefix ? props.idPrefix : "
|
|
1588
|
+
var componentId = useRef((props.idPrefix ? props.idPrefix : "MlImageMarkerLayer-") + v4());
|
|
1581
1589
|
var mapContext = useContext(MapContext);
|
|
1582
1590
|
var layerInitializedRef = useRef(false);
|
|
1583
1591
|
var idSuffixRef = useRef(props.idSuffix || new Date().getTime());
|
|
1584
1592
|
var imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
1585
|
-
var layerId = useRef(
|
|
1593
|
+
var layerId = useRef(props.layerId || componentId.current);
|
|
1586
1594
|
useEffect(function () {
|
|
1587
1595
|
var _componentId = componentId.current;
|
|
1588
1596
|
return function () {
|
|
@@ -1626,6 +1634,7 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1626
1634
|
|
|
1627
1635
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
1628
1636
|
layerInitializedRef.current = true;
|
|
1637
|
+
console.log(props.imgSrc);
|
|
1629
1638
|
|
|
1630
1639
|
if (props.imgSrc) {
|
|
1631
1640
|
mapRef.current.loadImage(props.imgSrc, function (error, image) {
|
|
@@ -1891,6 +1900,8 @@ MlNavigationCompass.propTypes = {
|
|
|
1891
1900
|
rotateLeftStyle: PropTypes.object
|
|
1892
1901
|
};
|
|
1893
1902
|
|
|
1903
|
+
var marker = "b556faa3bc6829d2.png";
|
|
1904
|
+
|
|
1894
1905
|
/**
|
|
1895
1906
|
* Adds a button that makes the map follow the users GPS position using
|
|
1896
1907
|
* navigator.geolocation.watchPosition if activated
|
|
@@ -1925,6 +1936,12 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1925
1936
|
var initializedRef = useRef(false);
|
|
1926
1937
|
var mapRef = useRef(undefined);
|
|
1927
1938
|
var componentId = useRef((props.idPrefix ? props.idPrefix : "MlFollowGps-") + v4());
|
|
1939
|
+
|
|
1940
|
+
var _useState7 = useState(30),
|
|
1941
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1942
|
+
accuracyRadius = _useState8[0],
|
|
1943
|
+
setAccuracyRadius = _useState8[1];
|
|
1944
|
+
|
|
1928
1945
|
useEffect(function () {
|
|
1929
1946
|
var _componentId = componentId.current;
|
|
1930
1947
|
return function () {
|
|
@@ -1957,6 +1974,7 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1957
1974
|
var getLocationSuccess = function getLocationSuccess(pos) {
|
|
1958
1975
|
if (!mapRef.current) return;
|
|
1959
1976
|
mapRef.current.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
|
1977
|
+
setAccuracyRadius(pos.coords.accuracy);
|
|
1960
1978
|
setGeoJson(point([pos.coords.longitude, pos.coords.latitude]));
|
|
1961
1979
|
};
|
|
1962
1980
|
|
|
@@ -1969,7 +1987,10 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1969
1987
|
geojson: geoJson,
|
|
1970
1988
|
type: "circle",
|
|
1971
1989
|
paint: {
|
|
1972
|
-
"circle-radius":
|
|
1990
|
+
"circle-radius": {
|
|
1991
|
+
stops: [[0, 0], [20, accuracyRadius / 0.075 / Math.cos(geoJson.geometry.coordinates[1] * Math.PI / 180)]],
|
|
1992
|
+
base: 2
|
|
1993
|
+
},
|
|
1973
1994
|
"circle-color": "#ee7700",
|
|
1974
1995
|
"circle-opacity": 0.5
|
|
1975
1996
|
}
|
|
@@ -1985,7 +2006,7 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1985
2006
|
"icon-offset": [0, -340]
|
|
1986
2007
|
}
|
|
1987
2008
|
},
|
|
1988
|
-
imgSrc:
|
|
2009
|
+
imgSrc: marker
|
|
1989
2010
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
1990
2011
|
sx: _objectSpread2({
|
|
1991
2012
|
zIndex: 1002,
|
|
@@ -2002,7 +2023,9 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
2002
2023
|
setIsFollowed(!isFollowed);
|
|
2003
2024
|
}
|
|
2004
2025
|
}, " ", /*#__PURE__*/React__default.createElement(RoomIcon, {
|
|
2005
|
-
sx: {
|
|
2026
|
+
sx: {
|
|
2027
|
+
fontSize: props.style.fontSize
|
|
2028
|
+
}
|
|
2006
2029
|
}), " "));
|
|
2007
2030
|
};
|
|
2008
2031
|
|
|
@@ -2016,6 +2039,7 @@ MlFollowGps.defaultProps = {
|
|
|
2016
2039
|
backgroundColor: "#414141",
|
|
2017
2040
|
borderRadius: "23%",
|
|
2018
2041
|
margin: 0.15,
|
|
2042
|
+
fontSize: "1.3em",
|
|
2019
2043
|
":hover": {
|
|
2020
2044
|
backgroundColor: "#515151",
|
|
2021
2045
|
color: "#ececec"
|
|
@@ -2050,17 +2074,19 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2050
2074
|
locationAccessDenied = _useState4[0],
|
|
2051
2075
|
setLocationAccessDenied = _useState4[1];
|
|
2052
2076
|
|
|
2077
|
+
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
2053
2078
|
var buttonStyle = {
|
|
2054
|
-
minWidth: "
|
|
2055
|
-
minHeight: "
|
|
2056
|
-
width: "30px",
|
|
2057
|
-
height: "30px",
|
|
2079
|
+
minWidth: "20px",
|
|
2080
|
+
minHeight: "20px",
|
|
2081
|
+
width: mediaIsMobile ? "50px" : "30px",
|
|
2082
|
+
height: mediaIsMobile ? "50px" : "30px",
|
|
2058
2083
|
color: "#bbb",
|
|
2059
2084
|
backgroundColor: "#414141",
|
|
2060
2085
|
borderRadius: "23%",
|
|
2061
2086
|
//border: "1px solid #bbb",
|
|
2062
2087
|
//boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
|
|
2063
2088
|
margin: 0.15,
|
|
2089
|
+
fontSize: mediaIsMobile ? "1.5em" : "1.2em",
|
|
2064
2090
|
":hover": {
|
|
2065
2091
|
backgroundColor: "#515151",
|
|
2066
2092
|
color: "#ececec"
|
|
@@ -2144,8 +2170,8 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2144
2170
|
style: {
|
|
2145
2171
|
zIndex: 501,
|
|
2146
2172
|
position: "absolute",
|
|
2147
|
-
right: "
|
|
2148
|
-
bottom: "20px",
|
|
2173
|
+
right: mediaIsMobile ? "15px" : "5px",
|
|
2174
|
+
bottom: mediaIsMobile ? "40px" : "20px",
|
|
2149
2175
|
display: "flex",
|
|
2150
2176
|
flexDirection: "column"
|
|
2151
2177
|
}
|
|
@@ -2153,15 +2179,15 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2153
2179
|
style: {
|
|
2154
2180
|
width: "31px",
|
|
2155
2181
|
position: "relative",
|
|
2156
|
-
height: "
|
|
2157
|
-
marginLeft: "-5px"
|
|
2182
|
+
height: mediaIsMobile ? "55px" : "45px",
|
|
2183
|
+
marginLeft: mediaIsMobile ? "3px" : "-5px",
|
|
2184
|
+
transform: mediaIsMobile ? "scale(1.6)" : "scale(1)"
|
|
2158
2185
|
},
|
|
2159
2186
|
backgroundStyle: {
|
|
2160
2187
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)"
|
|
2161
2188
|
}
|
|
2162
2189
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
2163
2190
|
sx: _objectSpread2(_objectSpread2({}, buttonStyle), {}, {
|
|
2164
|
-
fontSize: ".9em",
|
|
2165
2191
|
fontWeight: 600
|
|
2166
2192
|
}),
|
|
2167
2193
|
onClick: adjustPitch
|
|
@@ -2171,15 +2197,17 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2171
2197
|
disabled: locationAccessDenied
|
|
2172
2198
|
}, /*#__PURE__*/React__default.createElement(GpsFixedIcon, {
|
|
2173
2199
|
sx: {
|
|
2174
|
-
|
|
2200
|
+
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2175
2201
|
}
|
|
2176
|
-
})), /*#__PURE__*/React__default.createElement(MlFollowGps,
|
|
2202
|
+
})), /*#__PURE__*/React__default.createElement(MlFollowGps, {
|
|
2203
|
+
style: buttonStyle
|
|
2204
|
+
}), /*#__PURE__*/React__default.createElement(ButtonGroup, {
|
|
2177
2205
|
orientation: "vertical",
|
|
2178
2206
|
sx: {
|
|
2179
|
-
width: "
|
|
2207
|
+
width: "50px",
|
|
2180
2208
|
border: "none",
|
|
2181
2209
|
Button: {
|
|
2182
|
-
minWidth: "
|
|
2210
|
+
minWidth: "20px !important",
|
|
2183
2211
|
border: "none",
|
|
2184
2212
|
padding: 0
|
|
2185
2213
|
},
|
|
@@ -2190,10 +2218,18 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2190
2218
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
2191
2219
|
sx: buttonStyle,
|
|
2192
2220
|
onClick: zoomIn
|
|
2193
|
-
}, /*#__PURE__*/React__default.createElement(ControlPointIcon,
|
|
2221
|
+
}, /*#__PURE__*/React__default.createElement(ControlPointIcon, {
|
|
2222
|
+
sx: {
|
|
2223
|
+
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2224
|
+
}
|
|
2225
|
+
})), /*#__PURE__*/React__default.createElement(Button, {
|
|
2194
2226
|
sx: buttonStyle,
|
|
2195
2227
|
onClick: zoomOut
|
|
2196
|
-
}, /*#__PURE__*/React__default.createElement(RemoveCircleOutlineIcon,
|
|
2228
|
+
}, /*#__PURE__*/React__default.createElement(RemoveCircleOutlineIcon, {
|
|
2229
|
+
sx: {
|
|
2230
|
+
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2231
|
+
}
|
|
2232
|
+
}))));
|
|
2197
2233
|
};
|
|
2198
2234
|
|
|
2199
2235
|
var MlLayer = function MlLayer(props) {
|
|
@@ -2203,7 +2239,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2203
2239
|
var mapRef = useRef(null);
|
|
2204
2240
|
var componentId = useRef((props.layerId ? props.layerId : "MlLayer-") + v4());
|
|
2205
2241
|
var idSuffixRef = useRef(props.idSuffix || new Date().getTime());
|
|
2206
|
-
var layerId = (props.layerId ||
|
|
2242
|
+
var layerId = useRef(props.layerId || componentId.current);
|
|
2207
2243
|
var layerPaintConfRef = useRef(undefined);
|
|
2208
2244
|
var layerLayoutConfRef = useRef(undefined);
|
|
2209
2245
|
useEffect(function () {
|
|
@@ -2251,7 +2287,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2251
2287
|
|
|
2252
2288
|
layerInitializedRef.current = true;
|
|
2253
2289
|
mapRef.current.addLayer(_objectSpread2({
|
|
2254
|
-
id: layerId,
|
|
2290
|
+
id: layerId.current,
|
|
2255
2291
|
type: "background",
|
|
2256
2292
|
paint: {
|
|
2257
2293
|
"background-color": "rgba(0,0,0,0)"
|
|
@@ -2517,7 +2553,7 @@ var defaultProps = {
|
|
|
2517
2553
|
|
|
2518
2554
|
var MlWmsLayer = function MlWmsLayer(props) {
|
|
2519
2555
|
var mapContext = useContext(MapContext);
|
|
2520
|
-
var componentId = useRef(
|
|
2556
|
+
var componentId = useRef(props.layerId || "MlWmsLayer-" + v4());
|
|
2521
2557
|
var mapRef = useRef(null);
|
|
2522
2558
|
var initializedRef = useRef(false);
|
|
2523
2559
|
var layerId = useRef(props.layerId || componentId.current);
|
|
@@ -4123,7 +4159,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4123
4159
|
return false;
|
|
4124
4160
|
}
|
|
4125
4161
|
|
|
4126
|
-
if (!mapContext.
|
|
4162
|
+
if (!mapContext.getMap(props.map1Id) || !mapContext.getMap(props.map2Id)) {
|
|
4127
4163
|
return false;
|
|
4128
4164
|
}
|
|
4129
4165
|
|
|
@@ -4168,7 +4204,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4168
4204
|
useEffect(function () {
|
|
4169
4205
|
if (!mapExists() || syncMoveInitializedRef.current) return;
|
|
4170
4206
|
syncMoveInitializedRef.current = true;
|
|
4171
|
-
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id), mapContext.getMap(props.map2Id));
|
|
4207
|
+
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
4172
4208
|
|
|
4173
4209
|
if (mapContext.maps[props.map1Id].getCanvas().clientWidth > mapContext.maps[props.map1Id].getCanvas().clientHeight && magnifierRadiusRef.current * 2 > mapContext.maps[props.map1Id].getCanvas().clientHeight) {
|
|
4174
4210
|
magnifierRadiusRef.current = Math.floor(mapContext.maps[props.map1Id].getCanvas().clientHeight / 2);
|
|
@@ -4280,7 +4316,7 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4280
4316
|
return false;
|
|
4281
4317
|
}
|
|
4282
4318
|
|
|
4283
|
-
if (!mapContext.
|
|
4319
|
+
if (!mapContext.getMap(props.map1Id) || !mapContext.getMap(props.map2Id)) {
|
|
4284
4320
|
return false;
|
|
4285
4321
|
}
|
|
4286
4322
|
|
|
@@ -4313,7 +4349,7 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4313
4349
|
useEffect(function () {
|
|
4314
4350
|
if (!mapExists() || initializedRef.current) return;
|
|
4315
4351
|
initializedRef.current = true;
|
|
4316
|
-
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id), mapContext.getMap(props.map2Id));
|
|
4352
|
+
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
4317
4353
|
onMove({
|
|
4318
4354
|
clientX: mapContext.maps[props.map1Id].getCanvas().clientWidth / 2
|
|
4319
4355
|
});
|
|
@@ -4379,6 +4415,19 @@ MlLayerSwipe.propTypes = {
|
|
|
4379
4415
|
var GeoJsonContext = /*#__PURE__*/React__default.createContext({});
|
|
4380
4416
|
var GeoJsonContextProvider = GeoJsonContext.Provider;
|
|
4381
4417
|
|
|
4418
|
+
/**
|
|
4419
|
+
* https://github.com/mapbox/togeojson
|
|
4420
|
+
*
|
|
4421
|
+
* Copyright (c) 2016 Mapbox All rights reserved.
|
|
4422
|
+
*
|
|
4423
|
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4424
|
+
*
|
|
4425
|
+
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
4426
|
+
*
|
|
4427
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
4428
|
+
*
|
|
4429
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4430
|
+
*/
|
|
4382
4431
|
var toGeoJSON = function () {
|
|
4383
4432
|
var removeSpace = /\s*/g,
|
|
4384
4433
|
trimSpace = /^\s*|\s*$/g,
|
|
@@ -5019,6 +5068,7 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5019
5068
|
setMetaData = _useState6[1];
|
|
5020
5069
|
|
|
5021
5070
|
var fileupload = useRef(null);
|
|
5071
|
+
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
5022
5072
|
var popup = useRef(new Popup({
|
|
5023
5073
|
closeButton: false,
|
|
5024
5074
|
closeOnClick: true
|
|
@@ -5216,14 +5266,20 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5216
5266
|
fileupload.current.click();
|
|
5217
5267
|
};
|
|
5218
5268
|
|
|
5219
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(
|
|
5220
|
-
onClick: manualUpload,
|
|
5269
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
5221
5270
|
style: {
|
|
5222
|
-
position: "
|
|
5271
|
+
position: "fixed",
|
|
5223
5272
|
right: "5px",
|
|
5224
|
-
bottom: "
|
|
5225
|
-
|
|
5273
|
+
bottom: mediaIsMobile ? "40px" : "25px",
|
|
5274
|
+
display: "flex",
|
|
5275
|
+
flexDirection: "column",
|
|
5276
|
+
gap: "5px",
|
|
5226
5277
|
zIndex: 1000
|
|
5278
|
+
}
|
|
5279
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
5280
|
+
onClick: manualUpload,
|
|
5281
|
+
style: {
|
|
5282
|
+
backgroundColor: "rgba(255,255,255,1)"
|
|
5227
5283
|
},
|
|
5228
5284
|
size: "large"
|
|
5229
5285
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
@@ -5238,14 +5294,10 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5238
5294
|
}), /*#__PURE__*/React__default.createElement(FileCopy, null)), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
5239
5295
|
onClick: toogleDrawer,
|
|
5240
5296
|
style: {
|
|
5241
|
-
|
|
5242
|
-
right: "5px",
|
|
5243
|
-
bottom: "25px",
|
|
5244
|
-
backgroundColor: "rgba(255,255,255,1)",
|
|
5245
|
-
zIndex: 1000
|
|
5297
|
+
backgroundColor: "rgba(255,255,255,1)"
|
|
5246
5298
|
},
|
|
5247
5299
|
size: "large"
|
|
5248
|
-
}, /*#__PURE__*/React__default.createElement(InfoIcon, null)), /*#__PURE__*/React__default.createElement(Drawer, {
|
|
5300
|
+
}, /*#__PURE__*/React__default.createElement(InfoIcon, null))), /*#__PURE__*/React__default.createElement(Drawer, {
|
|
5249
5301
|
variant: "persistent",
|
|
5250
5302
|
anchor: "left",
|
|
5251
5303
|
open: open
|
|
@@ -5345,6 +5397,140 @@ GeoJsonProvider.propTypes = {
|
|
|
5345
5397
|
children: PropTypes.node.isRequired
|
|
5346
5398
|
};
|
|
5347
5399
|
|
|
5400
|
+
/**
|
|
5401
|
+
* MlSpatialElevationProfile returns a Button that will add a standard OSM tile layer to the maplibre-gl instance.
|
|
5402
|
+
*
|
|
5403
|
+
* @component
|
|
5404
|
+
*/
|
|
5405
|
+
|
|
5406
|
+
var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
|
|
5407
|
+
var mapContext = useContext(MapContext);
|
|
5408
|
+
var componentId = useRef((props.idPrefix ? props.idPrefix : "MlSpatialElevationProfile-") + v4());
|
|
5409
|
+
var mapRef = useRef(null);
|
|
5410
|
+
var initializedRef = useRef(false);
|
|
5411
|
+
var dataSource = useContext(GeoJsonContext);
|
|
5412
|
+
var sourceName = useRef("elevationprofile-" + v4());
|
|
5413
|
+
var layerName = useRef("elevationprofile-layer-" + v4());
|
|
5414
|
+
var createStep = useCallback(function (x, y, z, x2, y2) {
|
|
5415
|
+
//const summand = 0.0002;
|
|
5416
|
+
var line = lineString$1([[x, y], [x2, y2]]);
|
|
5417
|
+
var offsetLine = lineOffset(line, 5, {
|
|
5418
|
+
units: "meters"
|
|
5419
|
+
});
|
|
5420
|
+
var x3 = offsetLine.geometry.coordinates[0][0];
|
|
5421
|
+
var y3 = offsetLine.geometry.coordinates[0][1];
|
|
5422
|
+
var x4 = offsetLine.geometry.coordinates[1][0];
|
|
5423
|
+
var y4 = offsetLine.geometry.coordinates[1][1];
|
|
5424
|
+
return polygon([[[x, y], [x2, y2], [x4, y4], [x3, y3], [x, y]]], {
|
|
5425
|
+
height: z * props.elevationFactor
|
|
5426
|
+
});
|
|
5427
|
+
}, [props.elevationFactor]);
|
|
5428
|
+
useEffect(function () {
|
|
5429
|
+
var _componentId = componentId.current;
|
|
5430
|
+
return function () {
|
|
5431
|
+
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5432
|
+
if (mapRef.current) {
|
|
5433
|
+
mapRef.current.cleanup(_componentId);
|
|
5434
|
+
mapRef.current = null;
|
|
5435
|
+
}
|
|
5436
|
+
};
|
|
5437
|
+
}, []);
|
|
5438
|
+
useEffect(function () {
|
|
5439
|
+
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
5440
|
+
initializedRef.current = true;
|
|
5441
|
+
mapRef.current = mapContext.getMap(props.mapId);
|
|
5442
|
+
mapRef.current.addSource(sourceName.current, {
|
|
5443
|
+
type: "geojson",
|
|
5444
|
+
data: dataSource.data
|
|
5445
|
+
}, componentId.current);
|
|
5446
|
+
mapRef.current.addLayer({
|
|
5447
|
+
id: layerName.current,
|
|
5448
|
+
source: sourceName.current,
|
|
5449
|
+
type: "fill-extrusion",
|
|
5450
|
+
paint: {
|
|
5451
|
+
"fill-extrusion-height": ["get", "height"],
|
|
5452
|
+
"fill-extrusion-opacity": 0.9,
|
|
5453
|
+
"fill-extrusion-color": ["interpolate", ["linear"], ["get", "height"], 0, "rgba(0, 0, 255, 0)", 0.1, "royalblue", 0.3, "cyan", 0.5, "lime", 0.7, "yellow", 1, "yellow"]
|
|
5454
|
+
}
|
|
5455
|
+
}, props.insertBeforeLayer, componentId.current);
|
|
5456
|
+
}, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
|
|
5457
|
+
useEffect(function () {
|
|
5458
|
+
var _mapRef$current$getSo;
|
|
5459
|
+
|
|
5460
|
+
if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
|
|
5461
|
+
var data = dataSource.data;
|
|
5462
|
+
if (!data || !data.features) return;
|
|
5463
|
+
var line = data.features.find(function (element) {
|
|
5464
|
+
return element.geometry.type === "LineString";
|
|
5465
|
+
});
|
|
5466
|
+
if (!line || !line.geometry) return;
|
|
5467
|
+
var heights = line.geometry.coordinates.map(function (coordinate, index) {
|
|
5468
|
+
return coordinate[2];
|
|
5469
|
+
});
|
|
5470
|
+
var min = Math.min.apply(Math, _toConsumableArray(heights));
|
|
5471
|
+
var max = Math.max.apply(Math, _toConsumableArray(heights)) - min;
|
|
5472
|
+
max = max === 0 ? 1 : max;
|
|
5473
|
+
mapRef.current.setPaintProperty(layerName.current, "fill-extrusion-color", ["interpolate", ["linear"], ["get", "height"], 0, "rgb(0,255,55)", max * props.elevationFactor, "rgb(255,0,0)"]);
|
|
5474
|
+
|
|
5475
|
+
var lerp = function lerp(x, y, a) {
|
|
5476
|
+
return x * (1 - a) + y * a;
|
|
5477
|
+
};
|
|
5478
|
+
|
|
5479
|
+
var points = [];
|
|
5480
|
+
line.geometry.coordinates.forEach(function (coordinate, index) {
|
|
5481
|
+
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5482
|
+
//points.push(point);
|
|
5483
|
+
if (line.geometry.coordinates[index + 1]) {
|
|
5484
|
+
var wayLength = distance([coordinate[0], coordinate[1]], [line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]], {
|
|
5485
|
+
units: "kilometers"
|
|
5486
|
+
});
|
|
5487
|
+
var listLength = ~~(wayLength * 1000 / 10);
|
|
5488
|
+
listLength = listLength < 1 ? 1 : listLength;
|
|
5489
|
+
|
|
5490
|
+
for (var i = 0; i < listLength; i++) {
|
|
5491
|
+
var x = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], i / listLength);
|
|
5492
|
+
var y = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], i / listLength);
|
|
5493
|
+
var z = lerp(line.geometry.coordinates[index][2] - min, line.geometry.coordinates[index + 1][2] - min, i / listLength);
|
|
5494
|
+
var x2 = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], (i + 1) / listLength);
|
|
5495
|
+
var y2 = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], (i + 1) / listLength);
|
|
5496
|
+
var point = createStep(x, y, z, x2, y2);
|
|
5497
|
+
points.push(point);
|
|
5498
|
+
}
|
|
5499
|
+
}
|
|
5500
|
+
});
|
|
5501
|
+
var newData = dataSource.getEmptyFeatureCollection();
|
|
5502
|
+
newData.features = points;
|
|
5503
|
+
(_mapRef$current$getSo = mapRef.current.getSource(sourceName.current)) === null || _mapRef$current$getSo === void 0 ? void 0 : _mapRef$current$getSo.setData(newData);
|
|
5504
|
+
}, [dataSource.data, createStep, dataSource, props.elevationFactor, mapContext]);
|
|
5505
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
5506
|
+
};
|
|
5507
|
+
|
|
5508
|
+
MlSpatialElevationProfile.defaultProps = {
|
|
5509
|
+
elevationFactor: 1
|
|
5510
|
+
};
|
|
5511
|
+
MlSpatialElevationProfile.propTypes = {
|
|
5512
|
+
/**
|
|
5513
|
+
* Id of the target MapLibre instance in mapContext
|
|
5514
|
+
*/
|
|
5515
|
+
mapId: PropTypes.string,
|
|
5516
|
+
|
|
5517
|
+
/**
|
|
5518
|
+
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
5519
|
+
*/
|
|
5520
|
+
idPrefix: PropTypes.string,
|
|
5521
|
+
|
|
5522
|
+
/**
|
|
5523
|
+
* Number describes the factor of the height of the elevation
|
|
5524
|
+
*/
|
|
5525
|
+
elevationFactor: PropTypes.number,
|
|
5526
|
+
|
|
5527
|
+
/**
|
|
5528
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
5529
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
5530
|
+
*/
|
|
5531
|
+
insertBeforeLayer: PropTypes.string
|
|
5532
|
+
};
|
|
5533
|
+
|
|
5348
5534
|
/**
|
|
5349
5535
|
* React hook that allows subscribing to map state changes
|
|
5350
5536
|
*
|
|
@@ -5506,5 +5692,5 @@ useMapState.propTypes = {
|
|
|
5506
5692
|
})
|
|
5507
5693
|
};
|
|
5508
5694
|
|
|
5509
|
-
export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlVectorTileLayer, MlWmsLayer, useMapState };
|
|
5695
|
+
export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlVectorTileLayer, MlWmsLayer, useMapState };
|
|
5510
5696
|
//# sourceMappingURL=index.esm.js.map
|