@mapcomponents/react-maplibre 0.1.11 → 0.1.15
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/workflows/storybook.yml +10 -5
- package/coverage/clover.xml +894 -747
- package/coverage/coverage-final.json +22 -17
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +188 -122
- 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 +84 -69
- 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 +162 -48
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +311 -0
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +35 -29
- package/coverage/lcov-report/{components/MlImageMarkerLayer/MlImageMarkerLayer.js.html → src/components/MlLayer/MlLayer.js.html} +123 -126
- package/coverage/lcov-report/src/components/MlLayer/index.html +117 -0
- 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 +57 -42
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +25 -19
- 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 +224 -26
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +25 -19
- 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/src/hooks/index.html +147 -0
- package/coverage/lcov-report/{components/MlLayer/MlLayer.js.html → src/hooks/useMap.js.html} +86 -119
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +98 -92
- 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 +1620 -1306
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +976 -688
- 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 +53 -67
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +49 -46
- 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 +45 -9
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -57
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +28 -6
- 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 +29 -26
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlShareMapState/MlShareMapState.js +73 -9
- package/src/components/MlShareMapState/MlShareMapState.stories.js +24 -1
- 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 -2
- package/src/decorators/MapContextDecorator.js +7 -3
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
- package/src/decorators/MultiMapContextDecorator.js +2 -1
- package/src/hooks/useMap.js +36 -62
- package/src/hooks/useMapState.js +3 -3
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/index.js +3 -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/coverage/lcov-report/components/MlLayer/index.html +0 -111
- package/coverage/lcov-report/hooks/index.html +0 -141
- package/coverage/lcov-report/hooks/useMap.js.html +0 -377
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/react-maplibre",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@emotion/css": "^11.1.3",
|
|
10
10
|
"@emotion/react": "^11.4.1",
|
|
11
11
|
"@emotion/styled": "^11.3.0",
|
|
12
|
+
"@fontsource/roboto": "^4.5.1",
|
|
12
13
|
"@mapbox/mapbox-gl-draw": "^1.2.0",
|
|
13
14
|
"@mapbox/mapbox-gl-sync-move": "^0.3.0",
|
|
14
15
|
"@mapcomponents/react-core": "^0.1.1",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"@turf/turf": "^6.5.0",
|
|
19
20
|
"jspdf": "^2.3.0",
|
|
20
21
|
"maplibre-gl": "^1.13.0-rc.5",
|
|
22
|
+
"react-i18next": "^11.14.3",
|
|
21
23
|
"three": "^0.126.1",
|
|
22
24
|
"uuid": "^8.3.2",
|
|
23
25
|
"wms-capabilities": "^0.5.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/rollup.config.js
CHANGED
|
@@ -23,6 +23,12 @@ const config = {
|
|
|
23
23
|
css(),
|
|
24
24
|
del({ targets: ["dist/*"] }),
|
|
25
25
|
],
|
|
26
|
-
external: [
|
|
26
|
+
external: [
|
|
27
|
+
"prop-types",
|
|
28
|
+
"d3",
|
|
29
|
+
"@emotion/react",
|
|
30
|
+
"@emotion/styled",
|
|
31
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
32
|
+
],
|
|
27
33
|
};
|
|
28
34
|
export default config;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-ignore: TS export Problem to be fixed upstream
|
|
1
2
|
import maplibregl from "maplibre-gl/dist/maplibre-gl";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -41,7 +42,7 @@ const MapLibreGlWrapper = function (props) {
|
|
|
41
42
|
on: (eventName, handler, options, componentId) => {
|
|
42
43
|
if (!self.eventHandlers[eventName]) return;
|
|
43
44
|
|
|
44
|
-
if(typeof options ===
|
|
45
|
+
if (typeof options === "string") {
|
|
45
46
|
componentId = options;
|
|
46
47
|
options = {};
|
|
47
48
|
}
|
|
@@ -91,7 +92,7 @@ const MapLibreGlWrapper = function (props) {
|
|
|
91
92
|
/**
|
|
92
93
|
* Array containing an object for each layer in the MapLibre instance providing information on visibility, loading state, order, paint & layout properties
|
|
93
94
|
*/
|
|
94
|
-
layerState:
|
|
95
|
+
layerState: [],
|
|
95
96
|
/**
|
|
96
97
|
* Maps layerIds to layerState in JSON string form for quick deep comparisons
|
|
97
98
|
*/
|
|
@@ -108,38 +109,38 @@ const MapLibreGlWrapper = function (props) {
|
|
|
108
109
|
*/
|
|
109
110
|
buildLayerObject: (layer) => {
|
|
110
111
|
//if (self.baseLayers.indexOf(layer.id) === -1) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
112
|
+
let paint = {};
|
|
113
|
+
let values = layer.paint?._values;
|
|
114
|
+
Object.keys(values || {}).map((propName) => {
|
|
115
|
+
paint[propName] =
|
|
116
|
+
typeof values[propName].value !== "undefined"
|
|
117
|
+
? values[propName].value.value
|
|
118
|
+
: values[propName];
|
|
119
|
+
});
|
|
120
|
+
let layout = {};
|
|
121
|
+
values = layer.layout?._values;
|
|
122
|
+
Object.keys(values || {}).map((propName) => {
|
|
123
|
+
layout[propName] =
|
|
124
|
+
typeof values[propName].value !== "undefined"
|
|
125
|
+
? values[propName].value.value
|
|
126
|
+
: values[propName];
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
id: layer.id,
|
|
130
|
+
type: layer.type,
|
|
131
|
+
visible: layer.visibility === "none" ? false : true,
|
|
132
|
+
baseLayer: self.baseLayers.indexOf(layer.id) !== -1,
|
|
133
|
+
paint,
|
|
134
|
+
layout,
|
|
135
|
+
//filter: layers[layerId].filter,
|
|
136
|
+
//layout: layers[layerId].layout,
|
|
137
|
+
//maxzoom: layers[layerId].maxzoom,
|
|
138
|
+
//metadata: layers[layerId].metadata,
|
|
139
|
+
//minzoom: layers[layerId].minzoom,
|
|
140
|
+
//paint: layers[layerId].paint.get(),
|
|
141
|
+
//source: layers[layerId].source,
|
|
142
|
+
//sourceLayer: layers[layerId].sourceLayer,
|
|
143
|
+
};
|
|
143
144
|
//}
|
|
144
145
|
},
|
|
145
146
|
/**
|
|
@@ -159,7 +160,7 @@ const MapLibreGlWrapper = function (props) {
|
|
|
159
160
|
*/
|
|
160
161
|
refreshLayerState: () => {
|
|
161
162
|
self.wrapper.layerState = self.wrapper.buildLayerObjects();
|
|
162
|
-
self.wrapper.layerStateStrings = self.wrapper.layerState.map(el => JSON.stringify(el));
|
|
163
|
+
self.wrapper.layerStateStrings = self.wrapper.layerState.map((el) => JSON.stringify(el));
|
|
163
164
|
},
|
|
164
165
|
/**
|
|
165
166
|
* Object containing information on the current viewport state
|
|
@@ -173,29 +174,17 @@ const MapLibreGlWrapper = function (props) {
|
|
|
173
174
|
* Previous version of viewportStateString
|
|
174
175
|
*/
|
|
175
176
|
oldViewportStateString: "{}",
|
|
176
|
-
getViewport: () =>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
viewportRefreshWaiting: false,
|
|
184
|
-
refreshViewport: (force) => {
|
|
185
|
-
if (self.wrapper.viewportRefreshEnabled || force) {
|
|
186
|
-
self.wrapper.viewportRefreshEnabled = false;
|
|
187
|
-
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
188
|
-
self.wrapper.viewportStateString = JSON.stringify(self.wrapper.viewportState);
|
|
189
|
-
setTimeout(() => {
|
|
190
|
-
self.wrapper.viewportRefreshEnabled = true;
|
|
191
|
-
if (self.wrapper.viewportRefreshWaiting) {
|
|
192
|
-
self.wrapper.viewportRefreshWaiting = false;
|
|
193
|
-
self.wrapper.refreshViewport();
|
|
177
|
+
getViewport: () =>
|
|
178
|
+
typeof self.map.getCenter === "function"
|
|
179
|
+
? {
|
|
180
|
+
center: (({ lng, lat, ...rest }) => ({ lng, lat }))(self.map.getCenter()),
|
|
181
|
+
zoom: self.map.getZoom(),
|
|
182
|
+
bearing: self.map.getBearing(),
|
|
183
|
+
pitch: self.map.getPitch(),
|
|
194
184
|
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
185
|
+
: {},
|
|
186
|
+
refreshViewport: () => {
|
|
187
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
199
188
|
},
|
|
200
189
|
};
|
|
201
190
|
|
|
@@ -484,10 +473,10 @@ const MapLibreGlWrapper = function (props) {
|
|
|
484
473
|
) {
|
|
485
474
|
await fetch(props.mapOptions.style)
|
|
486
475
|
.then((response) => {
|
|
487
|
-
if(response.ok){
|
|
488
|
-
return response.json()
|
|
489
|
-
}else{
|
|
490
|
-
throw new Error(
|
|
476
|
+
if (response.ok) {
|
|
477
|
+
return response.json();
|
|
478
|
+
} else {
|
|
479
|
+
throw new Error("error loading map style.json");
|
|
491
480
|
}
|
|
492
481
|
})
|
|
493
482
|
.then((styleJson) => {
|
|
@@ -508,15 +497,12 @@ const MapLibreGlWrapper = function (props) {
|
|
|
508
497
|
self.map = new maplibregl.Map(props.mapOptions);
|
|
509
498
|
|
|
510
499
|
self.addNativeMaplibreFunctionsAndProps();
|
|
511
|
-
self.wrapper.refreshViewport(
|
|
500
|
+
self.wrapper.refreshViewport();
|
|
512
501
|
self.wrapper.fire("viewportchange");
|
|
513
502
|
|
|
514
503
|
self.map.on("move", () => {
|
|
515
|
-
self.wrapper.
|
|
516
|
-
|
|
517
|
-
self.wrapper.oldViewportStateString = self.wrapper.viewportStateString;
|
|
518
|
-
self.wrapper.fire("viewportchange");
|
|
519
|
-
}
|
|
504
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
505
|
+
self.wrapper.fire("viewportchange");
|
|
520
506
|
});
|
|
521
507
|
self.map.on("data", () => {
|
|
522
508
|
self.wrapper.refreshLayerState();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "MlFeatureEditor",
|
|
3
|
-
"title": "Sketch
|
|
3
|
+
"title": "Sketch tools",
|
|
4
4
|
"description": "Enables the editing of Point, Linestring and Polygon GeoJSON Files.",
|
|
5
5
|
"i18n": {
|
|
6
6
|
"de": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"description": "Ermöglicht das Bearbeiten von Punkt, Linestring und Polygon GeoJSON Daten."
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
|
-
"tags": [
|
|
11
|
+
"tags": ["Map add-on"],
|
|
12
12
|
"category": "add-ons",
|
|
13
13
|
"type": "component",
|
|
14
14
|
"price": 0
|
|
@@ -5,10 +5,12 @@ import {MapContext} from "@mapcomponents/react-core";
|
|
|
5
5
|
import {v4 as uuidv4} from "uuid";
|
|
6
6
|
import Button from "@mui/material/Button";
|
|
7
7
|
import RoomIcon from "@mui/icons-material/Room";
|
|
8
|
-
import {point} from "@turf/turf"
|
|
8
|
+
import {point, circle} from "@turf/turf"
|
|
9
9
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
10
10
|
import MlImageMarkerLayer from "../MlImageMarkerLayer/MlImageMarkerLayer";
|
|
11
11
|
|
|
12
|
+
import marker from "./assets/marker.png";
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Adds a button that makes the map follow the users GPS position using
|
|
14
16
|
* navigator.geolocation.watchPosition if activated
|
|
@@ -29,12 +31,11 @@ const MlFollowGps = (props) => {
|
|
|
29
31
|
const initializedRef = useRef(false);
|
|
30
32
|
const mapRef = useRef(undefined);
|
|
31
33
|
const componentId = useRef((props.idPrefix ? props.idPrefix : "MlFollowGps-") + uuidv4());
|
|
32
|
-
const [
|
|
34
|
+
const [accuracyGeoJson, setAccuracyGeoJson] = useState();
|
|
33
35
|
|
|
34
36
|
useEffect(() => {
|
|
35
37
|
let _componentId = componentId.current;
|
|
36
38
|
|
|
37
|
-
|
|
38
39
|
return () => {
|
|
39
40
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
40
41
|
// try to remove anything this component has added to the MapLibre-gl instance
|
|
@@ -61,14 +62,14 @@ const MlFollowGps = (props) => {
|
|
|
61
62
|
initializedRef.current = true;
|
|
62
63
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
63
64
|
mapRef.current.setCenter([7.132122000552613, 50.716405378037706]);
|
|
64
|
-
|
|
65
65
|
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
66
66
|
|
|
67
67
|
const getLocationSuccess = (pos) => {
|
|
68
68
|
if (!mapRef.current) return;
|
|
69
69
|
mapRef.current.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
|
70
|
-
|
|
71
|
-
setGeoJson(
|
|
70
|
+
const geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude])
|
|
71
|
+
setGeoJson(geoJsonPoint);
|
|
72
|
+
setAccuracyGeoJson(circle(geoJsonPoint, pos.coords.accuracy/1000))
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
const getLocationError = (err) => {
|
|
@@ -78,47 +79,38 @@ const MlFollowGps = (props) => {
|
|
|
78
79
|
|
|
79
80
|
return (
|
|
80
81
|
<>
|
|
81
|
-
{isFollowed && geoJson &&
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
layout: {
|
|
111
|
-
"icon-size": 0.1,
|
|
112
|
-
"icon-offset": [0, -340]
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
imgSrc={"/assets/marker.png"}
|
|
117
|
-
/>
|
|
118
|
-
}
|
|
82
|
+
{isFollowed && geoJson && (
|
|
83
|
+
<MlGeoJsonLayer
|
|
84
|
+
geojson={accuracyGeoJson}
|
|
85
|
+
type={"fill"}
|
|
86
|
+
paint={{
|
|
87
|
+
"fill-color": "#ee7700",
|
|
88
|
+
"fill-opacity": 0.5,
|
|
89
|
+
}}
|
|
90
|
+
insertBeforeLayer={"MlFollowGpsMarker"}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
|
|
94
|
+
{isFollowed && geoJson && (
|
|
95
|
+
<MlImageMarkerLayer
|
|
96
|
+
layerId={"MlFollowGpsMarker"}
|
|
97
|
+
options={{
|
|
98
|
+
type: "symbol",
|
|
99
|
+
source: {
|
|
100
|
+
type: "geojson",
|
|
101
|
+
data: geoJson,
|
|
102
|
+
},
|
|
103
|
+
layout: {
|
|
104
|
+
"icon-size": 0.1,
|
|
105
|
+
"icon-offset": [0, -340],
|
|
106
|
+
},
|
|
107
|
+
}}
|
|
108
|
+
imgSrc={marker}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
119
111
|
|
|
120
112
|
<Button
|
|
121
|
-
sx={{zIndex: 1002, color: isFollowed ?
|
|
113
|
+
sx={{ zIndex: 1002, color: isFollowed ? props.onColor : props.offColor, ...props.style }}
|
|
122
114
|
disabled={locationAccessDenied}
|
|
123
115
|
onClick={() => {
|
|
124
116
|
if (isFollowed) {
|
|
@@ -133,7 +125,7 @@ const MlFollowGps = (props) => {
|
|
|
133
125
|
}}
|
|
134
126
|
>
|
|
135
127
|
{" "}
|
|
136
|
-
<RoomIcon sx={{}}/>{" "}
|
|
128
|
+
<RoomIcon sx={{ fontSize: props.style.fontSize }} />{" "}
|
|
137
129
|
</Button>
|
|
138
130
|
</>
|
|
139
131
|
);
|
|
@@ -149,11 +141,14 @@ MlFollowGps.defaultProps = {
|
|
|
149
141
|
backgroundColor: "#414141",
|
|
150
142
|
borderRadius: "23%",
|
|
151
143
|
margin: 0.15,
|
|
144
|
+
fontSize: "1.3em",
|
|
152
145
|
":hover": {
|
|
153
146
|
backgroundColor: "#515151",
|
|
154
147
|
color: "#ececec",
|
|
155
148
|
},
|
|
156
149
|
},
|
|
150
|
+
onColor: "#ececec",
|
|
151
|
+
offColor: "#666"
|
|
157
152
|
};
|
|
158
153
|
|
|
159
154
|
MlFollowGps.propTypes = {
|
|
@@ -165,5 +160,13 @@ MlFollowGps.propTypes = {
|
|
|
165
160
|
* CSS style object that is applied to the button component
|
|
166
161
|
*/
|
|
167
162
|
style: PropTypes.object,
|
|
163
|
+
/**
|
|
164
|
+
* Active button font color
|
|
165
|
+
*/
|
|
166
|
+
onColor: PropTypes.string,
|
|
167
|
+
/**
|
|
168
|
+
* Inactive button font color
|
|
169
|
+
*/
|
|
170
|
+
offColor: PropTypes.string,
|
|
168
171
|
};
|
|
169
172
|
export default MlFollowGps;
|
|
Binary file
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useContext, useRef, useEffect, useState} from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import {MapContext} from "@mapcomponents/react-core";
|
|
4
|
+
import {bbox} from "@turf/turf";
|
|
5
5
|
import Divider from "@mui/material/Divider";
|
|
6
6
|
import Typography from "@mui/material/Typography";
|
|
7
7
|
import Drawer from "@mui/material/Drawer";
|
|
8
8
|
import IconButton from "@mui/material/IconButton";
|
|
9
9
|
import InfoIcon from "@mui/icons-material/Info";
|
|
10
10
|
import FileCopy from "@mui/icons-material/FileCopy";
|
|
11
|
-
import {
|
|
11
|
+
import {Popup} from "maplibre-gl";
|
|
12
12
|
import List from "@mui/material/List";
|
|
13
13
|
import ListItem from "@mui/material/ListItem";
|
|
14
14
|
import ListItemText from "@mui/material/ListItemText";
|
|
15
15
|
import GeoJsonContext from "./util/GeoJsonContext";
|
|
16
16
|
import toGeoJSON from "./gpxConverter";
|
|
17
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
17
18
|
|
|
18
|
-
import {
|
|
19
|
+
import {v4 as uuidv4} from "uuid";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* MlGPXViewer returns a dropzone and a button to load a GPX Track into the map.
|
|
@@ -38,6 +39,7 @@ const MlGPXViewer = (props) => {
|
|
|
38
39
|
const [zIndex, setZIndex] = useState(0);
|
|
39
40
|
const [metaData, setMetaData] = useState([]);
|
|
40
41
|
const fileupload = useRef(null);
|
|
42
|
+
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
41
43
|
|
|
42
44
|
const popup = useRef(
|
|
43
45
|
new Popup({
|
|
@@ -255,42 +257,42 @@ const MlGPXViewer = (props) => {
|
|
|
255
257
|
};
|
|
256
258
|
return (
|
|
257
259
|
<>
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
</
|
|
260
|
+
<div style={{
|
|
261
|
+
position: "fixed",
|
|
262
|
+
right: "5px",
|
|
263
|
+
bottom: mediaIsMobile ? "40px" : "25px",
|
|
264
|
+
display: "flex",
|
|
265
|
+
flexDirection: "column",
|
|
266
|
+
gap: "5px",
|
|
267
|
+
zIndex: 1000,
|
|
268
|
+
}}>
|
|
269
|
+
<IconButton
|
|
270
|
+
onClick={manualUpload}
|
|
271
|
+
style={{
|
|
272
|
+
backgroundColor: "rgba(255,255,255,1)",
|
|
273
|
+
}}
|
|
274
|
+
size="large"
|
|
275
|
+
>
|
|
276
|
+
<input
|
|
277
|
+
ref={fileupload}
|
|
278
|
+
onChange={fileUploadOnChange}
|
|
279
|
+
type="file"
|
|
280
|
+
id="input"
|
|
281
|
+
multiple
|
|
282
|
+
style={{display: "none"}}
|
|
283
|
+
></input>
|
|
284
|
+
<FileCopy/>
|
|
285
|
+
</IconButton>
|
|
286
|
+
<IconButton
|
|
287
|
+
onClick={toogleDrawer}
|
|
288
|
+
style={{
|
|
289
|
+
backgroundColor: "rgba(255,255,255,1)",
|
|
290
|
+
}}
|
|
291
|
+
size="large"
|
|
292
|
+
>
|
|
293
|
+
<InfoIcon/>
|
|
294
|
+
</IconButton>
|
|
295
|
+
</div>
|
|
294
296
|
<Drawer variant="persistent" anchor="left" open={open}>
|
|
295
297
|
<Typography
|
|
296
298
|
variant="h6"
|
|
@@ -302,11 +304,11 @@ const MlGPXViewer = (props) => {
|
|
|
302
304
|
>
|
|
303
305
|
Informationen zur Route
|
|
304
306
|
</Typography>
|
|
305
|
-
<Divider
|
|
307
|
+
<Divider/>
|
|
306
308
|
<List>
|
|
307
309
|
{metaData.map((item) => (
|
|
308
310
|
<ListItem key={`item--${item.id}`}>
|
|
309
|
-
<ListItemText primary={item.value}
|
|
311
|
+
<ListItemText primary={item.value}/>
|
|
310
312
|
</ListItem>
|
|
311
313
|
))}
|
|
312
314
|
</List>
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/mapbox/togeojson
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016 Mapbox All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
9
|
+
*
|
|
10
|
+
* 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.
|
|
11
|
+
*
|
|
12
|
+
* 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.
|
|
13
|
+
*/
|
|
1
14
|
var toGeoJSON = (function () {
|
|
2
15
|
var removeSpace = /\s*/g,
|
|
3
16
|
trimSpace = /^\s*|\s*$/g,
|
|
@@ -145,15 +158,11 @@ var toGeoJSON = (function () {
|
|
|
145
158
|
styleByHash[hash] = styles[k];
|
|
146
159
|
}
|
|
147
160
|
for (var l = 0; l < styleMaps.length; l++) {
|
|
148
|
-
styleIndex["#" + attr(styleMaps[l], "id")] = okhash(
|
|
149
|
-
xml2str(styleMaps[l])
|
|
150
|
-
).toString(16);
|
|
161
|
+
styleIndex["#" + attr(styleMaps[l], "id")] = okhash(xml2str(styleMaps[l])).toString(16);
|
|
151
162
|
var pairs = get(styleMaps[l], "Pair");
|
|
152
163
|
var pairsMap = {};
|
|
153
164
|
for (var m = 0; m < pairs.length; m++) {
|
|
154
|
-
pairsMap[nodeVal(get1(pairs[m], "key"))] = nodeVal(
|
|
155
|
-
get1(pairs[m], "styleUrl")
|
|
156
|
-
);
|
|
165
|
+
pairsMap[nodeVal(get1(pairs[m], "key"))] = nodeVal(get1(pairs[m], "styleUrl"));
|
|
157
166
|
}
|
|
158
167
|
styleMapIndex["#" + attr(styleMaps[l], "id")] = pairsMap;
|
|
159
168
|
}
|
|
@@ -183,8 +192,7 @@ var toGeoJSON = (function () {
|
|
|
183
192
|
coords = [],
|
|
184
193
|
times = [];
|
|
185
194
|
if (elems.length === 0) elems = get(root, "gx:coord");
|
|
186
|
-
for (var i = 0; i < elems.length; i++)
|
|
187
|
-
coords.push(gxCoord(nodeVal(elems[i])));
|
|
195
|
+
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
|
|
188
196
|
var timeElems = get(root, "when");
|
|
189
197
|
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
|
|
190
198
|
return {
|
|
@@ -322,26 +330,19 @@ var toGeoJSON = (function () {
|
|
|
322
330
|
outline = nodeVal(get1(polyStyle, "outline"));
|
|
323
331
|
if (pcolor) properties.fill = pcolor;
|
|
324
332
|
if (!isNaN(popacity)) properties["fill-opacity"] = popacity;
|
|
325
|
-
if (fill)
|
|
326
|
-
properties["fill-opacity"] =
|
|
327
|
-
fill === "1" ? properties["fill-opacity"] || 1 : 0;
|
|
333
|
+
if (fill) properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
|
|
328
334
|
if (outline)
|
|
329
|
-
properties["stroke-opacity"] =
|
|
330
|
-
outline === "1" ? properties["stroke-opacity"] || 1 : 0;
|
|
335
|
+
properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
|
|
331
336
|
}
|
|
332
337
|
if (extendedData) {
|
|
333
338
|
var datas = get(extendedData, "Data"),
|
|
334
339
|
simpleDatas = get(extendedData, "SimpleData");
|
|
335
340
|
|
|
336
341
|
for (i = 0; i < datas.length; i++) {
|
|
337
|
-
properties[datas[i].getAttribute("name")] = nodeVal(
|
|
338
|
-
get1(datas[i], "value")
|
|
339
|
-
);
|
|
342
|
+
properties[datas[i].getAttribute("name")] = nodeVal(get1(datas[i], "value"));
|
|
340
343
|
}
|
|
341
344
|
for (i = 0; i < simpleDatas.length; i++) {
|
|
342
|
-
properties[simpleDatas[i].getAttribute("name")] = nodeVal(
|
|
343
|
-
simpleDatas[i]
|
|
344
|
-
);
|
|
345
|
+
properties[simpleDatas[i].getAttribute("name")] = nodeVal(simpleDatas[i]);
|
|
345
346
|
}
|
|
346
347
|
}
|
|
347
348
|
if (visibility) {
|
|
@@ -444,8 +445,7 @@ var toGeoJSON = (function () {
|
|
|
444
445
|
if (track.length === 0) return;
|
|
445
446
|
var properties = getProperties(node);
|
|
446
447
|
extend(properties, getLineStyle(get1(node, "extensions")));
|
|
447
|
-
if (times.length)
|
|
448
|
-
properties.coordTimes = track.length === 1 ? times[0] : times;
|
|
448
|
+
if (times.length) properties.coordTimes = track.length === 1 ? times[0] : times;
|
|
449
449
|
if (heartRates.length)
|
|
450
450
|
properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;
|
|
451
451
|
return {
|
|
@@ -501,14 +501,7 @@ var toGeoJSON = (function () {
|
|
|
501
501
|
return style;
|
|
502
502
|
}
|
|
503
503
|
function getProperties(node) {
|
|
504
|
-
var prop = getMulti(node, [
|
|
505
|
-
"name",
|
|
506
|
-
"cmt",
|
|
507
|
-
"desc",
|
|
508
|
-
"type",
|
|
509
|
-
"time",
|
|
510
|
-
"keywords",
|
|
511
|
-
]),
|
|
504
|
+
var prop = getMulti(node, ["name", "cmt", "desc", "type", "time", "keywords"]),
|
|
512
505
|
links = get(node, "link");
|
|
513
506
|
if (links.length) prop.links = [];
|
|
514
507
|
for (var i = 0, link; i < links.length; i++) {
|