@mapcomponents/react-maplibre 0.1.9 → 0.1.13
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 +170 -109
- 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 +10 -2
- 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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/react-maplibre",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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
|
@@ -11,7 +11,9 @@ const config = {
|
|
|
11
11
|
input: pkg.source,
|
|
12
12
|
output: [{ file: pkg.module, format: "esm", sourcemap: true }],
|
|
13
13
|
plugins: [
|
|
14
|
-
svgr(
|
|
14
|
+
svgr({
|
|
15
|
+
svgo: false,
|
|
16
|
+
}),
|
|
15
17
|
url(),
|
|
16
18
|
external(),
|
|
17
19
|
babel({
|
|
@@ -21,6 +23,12 @@ const config = {
|
|
|
21
23
|
css(),
|
|
22
24
|
del({ targets: ["dist/*"] }),
|
|
23
25
|
],
|
|
24
|
-
external: [
|
|
26
|
+
external: [
|
|
27
|
+
"prop-types",
|
|
28
|
+
"d3",
|
|
29
|
+
"@emotion/react",
|
|
30
|
+
"@emotion/styled",
|
|
31
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
32
|
+
],
|
|
25
33
|
};
|
|
26
34
|
export default config;
|
|
@@ -41,7 +41,7 @@ const MapLibreGlWrapper = function (props) {
|
|
|
41
41
|
on: (eventName, handler, options, componentId) => {
|
|
42
42
|
if (!self.eventHandlers[eventName]) return;
|
|
43
43
|
|
|
44
|
-
if(typeof options ===
|
|
44
|
+
if (typeof options === "string") {
|
|
45
45
|
componentId = options;
|
|
46
46
|
options = {};
|
|
47
47
|
}
|
|
@@ -108,38 +108,38 @@ const MapLibreGlWrapper = function (props) {
|
|
|
108
108
|
*/
|
|
109
109
|
buildLayerObject: (layer) => {
|
|
110
110
|
//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
|
-
|
|
111
|
+
let paint = {};
|
|
112
|
+
let values = layer.paint?._values;
|
|
113
|
+
Object.keys(values || {}).map((propName) => {
|
|
114
|
+
paint[propName] =
|
|
115
|
+
typeof values[propName].value !== "undefined"
|
|
116
|
+
? values[propName].value.value
|
|
117
|
+
: values[propName];
|
|
118
|
+
});
|
|
119
|
+
let layout = {};
|
|
120
|
+
values = layer.layout?._values;
|
|
121
|
+
Object.keys(values || {}).map((propName) => {
|
|
122
|
+
layout[propName] =
|
|
123
|
+
typeof values[propName].value !== "undefined"
|
|
124
|
+
? values[propName].value.value
|
|
125
|
+
: values[propName];
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
id: layer.id,
|
|
129
|
+
type: layer.type,
|
|
130
|
+
visible: layer.visibility === "none" ? false : true,
|
|
131
|
+
baseLayer: self.baseLayers.indexOf(layer.id) !== -1,
|
|
132
|
+
paint,
|
|
133
|
+
layout,
|
|
134
|
+
//filter: layers[layerId].filter,
|
|
135
|
+
//layout: layers[layerId].layout,
|
|
136
|
+
//maxzoom: layers[layerId].maxzoom,
|
|
137
|
+
//metadata: layers[layerId].metadata,
|
|
138
|
+
//minzoom: layers[layerId].minzoom,
|
|
139
|
+
//paint: layers[layerId].paint.get(),
|
|
140
|
+
//source: layers[layerId].source,
|
|
141
|
+
//sourceLayer: layers[layerId].sourceLayer,
|
|
142
|
+
};
|
|
143
143
|
//}
|
|
144
144
|
},
|
|
145
145
|
/**
|
|
@@ -159,7 +159,7 @@ const MapLibreGlWrapper = function (props) {
|
|
|
159
159
|
*/
|
|
160
160
|
refreshLayerState: () => {
|
|
161
161
|
self.wrapper.layerState = self.wrapper.buildLayerObjects();
|
|
162
|
-
self.wrapper.layerStateStrings = self.wrapper.layerState.map(el => JSON.stringify(el));
|
|
162
|
+
self.wrapper.layerStateStrings = self.wrapper.layerState.map((el) => JSON.stringify(el));
|
|
163
163
|
},
|
|
164
164
|
/**
|
|
165
165
|
* Object containing information on the current viewport state
|
|
@@ -173,29 +173,17 @@ const MapLibreGlWrapper = function (props) {
|
|
|
173
173
|
* Previous version of viewportStateString
|
|
174
174
|
*/
|
|
175
175
|
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();
|
|
176
|
+
getViewport: () =>
|
|
177
|
+
typeof self.map.getCenter === "function"
|
|
178
|
+
? {
|
|
179
|
+
center: (({ lng, lat, ...rest }) => ({ lng, lat }))(self.map.getCenter()),
|
|
180
|
+
zoom: self.map.getZoom(),
|
|
181
|
+
bearing: self.map.getBearing(),
|
|
182
|
+
pitch: self.map.getPitch(),
|
|
194
183
|
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
184
|
+
: {},
|
|
185
|
+
refreshViewport: () => {
|
|
186
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
199
187
|
},
|
|
200
188
|
};
|
|
201
189
|
|
|
@@ -484,10 +472,10 @@ const MapLibreGlWrapper = function (props) {
|
|
|
484
472
|
) {
|
|
485
473
|
await fetch(props.mapOptions.style)
|
|
486
474
|
.then((response) => {
|
|
487
|
-
if(response.ok){
|
|
488
|
-
return response.json()
|
|
489
|
-
}else{
|
|
490
|
-
throw new Error(
|
|
475
|
+
if (response.ok) {
|
|
476
|
+
return response.json();
|
|
477
|
+
} else {
|
|
478
|
+
throw new Error("error loading map style.json");
|
|
491
479
|
}
|
|
492
480
|
})
|
|
493
481
|
.then((styleJson) => {
|
|
@@ -508,23 +496,20 @@ const MapLibreGlWrapper = function (props) {
|
|
|
508
496
|
self.map = new maplibregl.Map(props.mapOptions);
|
|
509
497
|
|
|
510
498
|
self.addNativeMaplibreFunctionsAndProps();
|
|
511
|
-
self.wrapper.refreshViewport(
|
|
499
|
+
self.wrapper.refreshViewport();
|
|
512
500
|
self.wrapper.fire("viewportchange");
|
|
513
501
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if (self.wrapper.viewportStateString !== self.wrapper.oldViewportStateString) {
|
|
517
|
-
self.wrapper.oldViewportStateString = self.wrapper.viewportStateString;
|
|
502
|
+
self.map.on("move", () => {
|
|
503
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
518
504
|
self.wrapper.fire("viewportchange");
|
|
505
|
+
});
|
|
506
|
+
self.map.on("data", () => {
|
|
507
|
+
self.wrapper.refreshLayerState();
|
|
508
|
+
self.wrapper.fire("layerchange");
|
|
509
|
+
});
|
|
510
|
+
if (typeof props.onReady === "function") {
|
|
511
|
+
props.onReady(self.map, self);
|
|
519
512
|
}
|
|
520
|
-
});
|
|
521
|
-
self.map.on("data", () => {
|
|
522
|
-
self.wrapper.refreshLayerState();
|
|
523
|
-
self.wrapper.fire("layerchange");
|
|
524
|
-
});
|
|
525
|
-
if (typeof props.onReady === "function") {
|
|
526
|
-
props.onReady(self.map, self);
|
|
527
|
-
}
|
|
528
513
|
};
|
|
529
514
|
initializeMapLibre();
|
|
530
515
|
};
|
|
@@ -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
|
|
@@ -9,6 +9,8 @@ import {point} 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,11 +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());
|
|
34
|
+
const [accuracyRadius, setAccuracyRadius] = useState(30);
|
|
32
35
|
|
|
33
36
|
useEffect(() => {
|
|
34
37
|
let _componentId = componentId.current;
|
|
35
38
|
|
|
36
|
-
|
|
37
39
|
return () => {
|
|
38
40
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
39
41
|
// try to remove anything this component has added to the MapLibre-gl instance
|
|
@@ -60,12 +62,12 @@ const MlFollowGps = (props) => {
|
|
|
60
62
|
initializedRef.current = true;
|
|
61
63
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
62
64
|
mapRef.current.setCenter([7.132122000552613, 50.716405378037706]);
|
|
63
|
-
|
|
64
65
|
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
65
66
|
|
|
66
67
|
const getLocationSuccess = (pos) => {
|
|
67
68
|
if (!mapRef.current) return;
|
|
68
69
|
mapRef.current.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
|
70
|
+
setAccuracyRadius(pos.coords.accuracy);
|
|
69
71
|
setGeoJson(point([pos.coords.longitude, pos.coords.latitude]));
|
|
70
72
|
};
|
|
71
73
|
|
|
@@ -76,36 +78,48 @@ const MlFollowGps = (props) => {
|
|
|
76
78
|
|
|
77
79
|
return (
|
|
78
80
|
<>
|
|
79
|
-
{isFollowed && geoJson &&
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
81
|
+
{isFollowed && geoJson && (
|
|
82
|
+
<MlGeoJsonLayer
|
|
83
|
+
geojson={geoJson}
|
|
84
|
+
type={"circle"}
|
|
85
|
+
paint={{
|
|
86
|
+
"circle-radius": {
|
|
87
|
+
stops: [
|
|
88
|
+
[0, 0],
|
|
89
|
+
[
|
|
90
|
+
20,
|
|
91
|
+
accuracyRadius /
|
|
92
|
+
0.075 /
|
|
93
|
+
Math.cos((geoJson.geometry.coordinates[1] * Math.PI) / 180),
|
|
94
|
+
],
|
|
95
|
+
],
|
|
96
|
+
base: 2,
|
|
97
|
+
},
|
|
98
|
+
"circle-color": "#ee7700",
|
|
99
|
+
"circle-opacity": 0.5,
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{isFollowed && geoJson && (
|
|
105
|
+
<MlImageMarkerLayer
|
|
106
|
+
options={{
|
|
107
|
+
type: "symbol",
|
|
108
|
+
source: {
|
|
109
|
+
type: "geojson",
|
|
110
|
+
data: geoJson,
|
|
111
|
+
},
|
|
112
|
+
layout: {
|
|
113
|
+
"icon-size": 0.1,
|
|
114
|
+
"icon-offset": [0, -340],
|
|
115
|
+
},
|
|
116
|
+
}}
|
|
117
|
+
imgSrc={marker}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
106
120
|
|
|
107
121
|
<Button
|
|
108
|
-
sx={{zIndex: 1002, color: isFollowed ? "#bbb" : "#666", ...props.style}}
|
|
122
|
+
sx={{ zIndex: 1002, color: isFollowed ? "#bbb" : "#666", ...props.style }}
|
|
109
123
|
disabled={locationAccessDenied}
|
|
110
124
|
onClick={() => {
|
|
111
125
|
if (isFollowed) {
|
|
@@ -120,7 +134,7 @@ const MlFollowGps = (props) => {
|
|
|
120
134
|
}}
|
|
121
135
|
>
|
|
122
136
|
{" "}
|
|
123
|
-
<RoomIcon sx={{}}/>{" "}
|
|
137
|
+
<RoomIcon sx={{fontSize: props.style.fontSize}}/>{" "}
|
|
124
138
|
</Button>
|
|
125
139
|
</>
|
|
126
140
|
);
|
|
@@ -136,6 +150,7 @@ MlFollowGps.defaultProps = {
|
|
|
136
150
|
backgroundColor: "#414141",
|
|
137
151
|
borderRadius: "23%",
|
|
138
152
|
margin: 0.15,
|
|
153
|
+
fontSize: "1.3em",
|
|
139
154
|
":hover": {
|
|
140
155
|
backgroundColor: "#515151",
|
|
141
156
|
color: "#ececec",
|
|
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++) {
|