@mapcomponents/react-maplibre 0.1.12 → 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.
Files changed (120) hide show
  1. package/coverage/clover.xml +727 -608
  2. package/coverage/coverage-final.json +19 -14
  3. package/coverage/lcov-report/index.html +156 -96
  4. package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +10 -10
  5. package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +10 -10
  6. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +10 -10
  7. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +10 -10
  8. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +10 -10
  9. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +10 -10
  10. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +10 -10
  11. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +10 -10
  12. package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +61 -55
  13. package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +10 -10
  14. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +66 -60
  15. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +49 -70
  16. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +25 -25
  17. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +70 -28
  18. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +27 -27
  19. package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/MlImageMarkerLayer.js.html +19 -22
  20. package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +19 -19
  21. package/coverage/lcov-report/{components → src/components}/MlLayer/MlLayer.js.html +30 -30
  22. package/coverage/lcov-report/{components → src/components}/MlLayer/index.html +26 -26
  23. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +41 -41
  24. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +24 -24
  25. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +38 -41
  26. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +24 -24
  27. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
  28. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
  31. package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +11 -11
  32. package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +10 -10
  33. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +10 -10
  34. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +10 -10
  35. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +48 -36
  36. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +16 -16
  37. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +10 -10
  38. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +10 -10
  39. package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +10 -10
  40. package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +10 -10
  41. package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +10 -10
  42. package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +10 -10
  43. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +10 -10
  44. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +10 -10
  45. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +30 -54
  46. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +24 -24
  47. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +10 -10
  48. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +10 -10
  49. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +10 -10
  50. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +10 -10
  51. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +10 -10
  52. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +10 -10
  53. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +13 -13
  54. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +14 -14
  55. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +31 -19
  56. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +16 -16
  57. package/coverage/lcov-report/{hooks → src/hooks}/index.html +10 -10
  58. package/coverage/lcov-report/{hooks → src/hooks}/useMap.js.html +10 -10
  59. package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +10 -10
  60. package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +18 -18
  61. package/coverage/lcov-report/src/i18n.js.html +167 -0
  62. package/coverage/lcov-report/src/index.html +117 -0
  63. package/coverage/lcov-report/src/translations/english.js.html +95 -0
  64. package/coverage/lcov-report/src/translations/german.js.html +95 -0
  65. package/coverage/lcov-report/src/translations/index.html +132 -0
  66. package/coverage/lcov.info +1240 -976
  67. package/dist/b556faa3bc6829d2.png +0 -0
  68. package/dist/index.esm.js +102 -71
  69. package/dist/index.esm.js.map +1 -1
  70. package/package.json +3 -1
  71. package/public/assets/dop.png +0 -0
  72. package/public/assets/historic.png +0 -0
  73. package/public/assets/osm.png +0 -0
  74. package/public/thumbnails/MlFollowGps.png +0 -0
  75. package/public/thumbnails/MlThreeJsLayer.png +0 -0
  76. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +58 -73
  77. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
  78. package/src/components/MlFollowGps/MlFollowGps.js +45 -43
  79. package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
  80. package/src/components/MlFollowGps/assets/marker.png +0 -0
  81. package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
  82. package/src/components/MlGPXViewer/gpxConverter.js +22 -29
  83. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +22 -8
  84. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +3 -4
  85. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
  86. package/src/components/MlLayer/MlLayer.js +2 -2
  87. package/src/components/MlLayer/MlLayer.test.js +12 -10
  88. package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
  89. package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
  90. package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
  91. package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
  92. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
  93. package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
  94. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
  95. package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
  96. package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
  97. package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
  98. package/src/components/MlMarker/MlMarker.js +1 -1
  99. package/src/components/MlNavigationTools/MlNavigationTools.js +26 -22
  100. package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
  101. package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
  102. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
  103. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
  104. package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
  105. package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
  106. package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
  107. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
  108. package/src/decorators/EmptyMapContextDecorator.js +11 -6
  109. package/src/decorators/MapContext3DDecorator.js +25 -20
  110. package/src/decorators/MapContextDashboardDecorator.js +7 -2
  111. package/src/decorators/MapContextDecorator.js +7 -3
  112. package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
  113. package/src/decorators/MultiMapContextDecorator.js +2 -1
  114. package/src/hooks/useWms.js +7 -6
  115. package/src/i18n.js +28 -0
  116. package/src/translations/english.js +4 -0
  117. package/src/translations/german.js +4 -0
  118. package/src/ui_components/ImageLoader.js +73 -0
  119. package/src/ui_components/Sidebar.js +75 -20
  120. 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.12",
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
@@ -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 === 'string'){
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
- 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
- };
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: () => (typeof self.map.getCenter === 'function'?{
177
- center: (({ lng, lat, ...rest }) => ({ lng, lat }))(self.map.getCenter()),
178
- zoom: self.map.getZoom(),
179
- bearing: self.map.getBearing(),
180
- pitch: self.map.getPitch(),
181
- }:{}),
182
- viewportRefreshEnabled: true,
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
- }, 50);
196
- }else{
197
- self.wrapper.viewportRefreshWaiting = true;
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('error loading map style.json')
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(true);
499
+ self.wrapper.refreshViewport();
512
500
  self.wrapper.fire("viewportchange");
513
501
 
514
- self.map.on("move", () => {
515
- self.wrapper.refreshViewport();
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 Tool",
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": [ "Map add-on" ],
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
@@ -34,7 +36,6 @@ const MlFollowGps = (props) => {
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,13 +62,12 @@ 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
- setAccuracyRadius(pos.coords.accuracy)
70
+ setAccuracyRadius(pos.coords.accuracy);
71
71
  setGeoJson(point([pos.coords.longitude, pos.coords.latitude]));
72
72
  };
73
73
 
@@ -78,47 +78,48 @@ const MlFollowGps = (props) => {
78
78
 
79
79
  return (
80
80
  <>
81
- {isFollowed && geoJson &&
82
- <MlGeoJsonLayer geojson={geoJson} type={"circle"}
83
- paint={{
84
- "circle-radius": {
85
- stops: [
86
- [0, 0],
87
- [
88
- 20,
89
- (accuracyRadius) /
90
- 0.075 /
91
- Math.cos((geoJson.geometry.coordinates[1] * Math.PI) / 180),
92
- ],
93
- ],
94
- base: 2,
95
- },
96
- "circle-color": "#ee7700",
97
- "circle-opacity": 0.5,
98
- }}
99
- />
100
- }
101
-
102
- {isFollowed && geoJson &&
103
- <MlImageMarkerLayer
104
- options={{
105
- type: "symbol",
106
- source: {
107
- type: "geojson",
108
- data: geoJson
109
- },
110
- layout: {
111
- "icon-size": 0.1,
112
- "icon-offset": [0, -340]
113
- },
114
- }
115
- }
116
- imgSrc={"/assets/marker.png"}
117
- />
118
- }
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
+ )}
119
120
 
120
121
  <Button
121
- sx={{zIndex: 1002, color: isFollowed ? "#bbb" : "#666", ...props.style}}
122
+ sx={{ zIndex: 1002, color: isFollowed ? "#bbb" : "#666", ...props.style }}
122
123
  disabled={locationAccessDenied}
123
124
  onClick={() => {
124
125
  if (isFollowed) {
@@ -133,7 +134,7 @@ const MlFollowGps = (props) => {
133
134
  }}
134
135
  >
135
136
  {" "}
136
- <RoomIcon sx={{}}/>{" "}
137
+ <RoomIcon sx={{fontSize: props.style.fontSize}}/>{" "}
137
138
  </Button>
138
139
  </>
139
140
  );
@@ -149,6 +150,7 @@ MlFollowGps.defaultProps = {
149
150
  backgroundColor: "#414141",
150
151
  borderRadius: "23%",
151
152
  margin: 0.15,
153
+ fontSize: "1.3em",
152
154
  ":hover": {
153
155
  backgroundColor: "#515151",
154
156
  color: "#ececec",
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "MlFollowGPS",
3
- "title": "GPS-Tracker",
2
+ "name": "MlFollowGps",
3
+ "title": "GPS tracker",
4
4
  "description": "",
5
5
  "i18n": {
6
6
  "de": {
@@ -1,21 +1,22 @@
1
- import React, { useContext, useRef, useEffect, useState } from "react";
1
+ import React, {useContext, useRef, useEffect, useState} from "react";
2
2
  import PropTypes from "prop-types";
3
- import { MapContext } from "@mapcomponents/react-core";
4
- import { bbox } from "@turf/turf";
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 { Popup } from "maplibre-gl";
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 { v4 as uuidv4 } from "uuid";
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
- <IconButton
259
- onClick={manualUpload}
260
- style={{
261
- position: "absolute",
262
- right: "5px",
263
- bottom: "75px",
264
- backgroundColor: "rgba(255,255,255,1)",
265
-
266
- zIndex: 1000,
267
- }}
268
- size="large"
269
- >
270
- <input
271
- ref={fileupload}
272
- onChange={fileUploadOnChange}
273
- type="file"
274
- id="input"
275
- multiple
276
- style={{ display: "none" }}
277
- ></input>
278
- <FileCopy />
279
- </IconButton>
280
- <IconButton
281
- onClick={toogleDrawer}
282
- style={{
283
- position: "absolute",
284
- right: "5px",
285
- bottom: "25px",
286
- backgroundColor: "rgba(255,255,255,1)",
287
-
288
- zIndex: 1000,
289
- }}
290
- size="large"
291
- >
292
- <InfoIcon />
293
- </IconButton>
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++) {