@mapcomponents/react-maplibre 0.1.24 → 0.1.25

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 (71) hide show
  1. package/coverage/clover.xml +22 -27
  2. package/coverage/coverage-final.json +1 -1
  3. package/coverage/lcov-report/index.html +18 -18
  4. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +1 -1
  5. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  6. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +1 -1
  7. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  8. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +1 -1
  9. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  10. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +1 -1
  11. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  12. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +30 -93
  13. package/coverage/lcov-report/src/components/MlFollowGps/index.html +18 -18
  14. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +1 -1
  15. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
  16. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +1 -1
  18. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +1 -1
  20. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  21. package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +1 -1
  22. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  23. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +1 -1
  24. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  25. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +1 -1
  26. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  27. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  28. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  31. package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +1 -1
  32. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +1 -1
  34. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  35. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +1 -1
  36. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  38. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  39. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  40. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  41. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  42. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
  44. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  46. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  48. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +1 -1
  50. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +1 -1
  54. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  57. package/coverage/lcov-report/src/hooks/index.html +1 -1
  58. package/coverage/lcov-report/src/hooks/useMap.js.html +1 -1
  59. package/coverage/lcov-report/src/hooks/useMapState.js.html +1 -1
  60. package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
  61. package/coverage/lcov-report/src/i18n.js.html +1 -1
  62. package/coverage/lcov-report/src/index.html +1 -1
  63. package/coverage/lcov-report/src/translations/english.js.html +1 -1
  64. package/coverage/lcov-report/src/translations/german.js.html +1 -1
  65. package/coverage/lcov-report/src/translations/index.html +1 -1
  66. package/coverage/lcov.info +43 -54
  67. package/dist/index.esm.js +18 -39
  68. package/dist/index.esm.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/components/MlFollowGps/MlFollowGps.js +18 -39
  71. package/src/components/MlFollowGps/MlFollowGps.test.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "module": "dist/index.esm.js",
@@ -24,20 +24,10 @@ const MlFollowGps = (props) => {
24
24
 
25
25
  const [isFollowed, setIsFollowed] = useState(false);
26
26
  const [geoJson, setGeoJson] = useState(undefined);
27
- const watchIdRef = useRef(undefined);
28
27
  const [locationAccessDenied, setLocationAccessDenied] = useState(false);
29
28
 
30
29
  const [accuracyGeoJson, setAccuracyGeoJson] = useState();
31
30
 
32
- useEffect(() => {
33
- return () => {
34
- if (watchIdRef.current) {
35
- navigator.geolocation.clearWatch(watchIdRef.current);
36
- watchIdRef.current = undefined;
37
- }
38
- };
39
- }, []);
40
-
41
31
  const getLocationSuccess = useCallback(
42
32
  (pos) => {
43
33
  if (!mapHook.map) return;
@@ -59,12 +49,11 @@ const MlFollowGps = (props) => {
59
49
  if (!mapHook.map) return;
60
50
 
61
51
  if (isFollowed) {
62
- watchIdRef.current = navigator.geolocation.watchPosition(
63
- getLocationSuccess,
64
- getLocationError
65
- );
66
- } else {
67
- navigator.geolocation.clearWatch(watchIdRef.current);
52
+ let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
53
+
54
+ return () => {
55
+ navigator.geolocation.clearWatch(_watchId);
56
+ };
68
57
  }
69
58
  }, [isFollowed, getLocationSuccess]);
70
59
 
@@ -79,26 +68,20 @@ const MlFollowGps = (props) => {
79
68
  "fill-opacity": 0.5,
80
69
  ...props.accuracyPaint,
81
70
  }}
82
- insertBeforeLayer={"MlFollowGpsMarker"}
71
+ insertBeforeLayer={props.insertBeforeLayer}
83
72
  />
84
73
  )}
85
74
 
86
75
  {isFollowed && geoJson && (
87
- <MlImageMarkerLayer
88
- layerId={"MlFollowGpsMarker"}
89
- options={{
90
- type: "symbol",
91
- source: {
92
- type: "geojson",
93
- data: geoJson,
94
- },
95
- layout: {
96
- "icon-size": 0.1,
97
- "icon-offset": [0, -340],
98
- ...props.markerLayout,
99
- },
76
+ <MlGeoJsonLayer
77
+ geojson={geoJson}
78
+ type={"circle"}
79
+ paint={{
80
+ "circle-color": "#ee9900",
81
+ "circle-radius": 5,
82
+ ...props.circlePaint,
100
83
  }}
101
- imgSrc={props.markerImage || marker}
84
+ insertBeforeLayer={props.insertBeforeLayer}
102
85
  />
103
86
  )}
104
87
 
@@ -160,14 +143,10 @@ MlFollowGps.propTypes = {
160
143
  */
161
144
  accuracyPaint: PropTypes.object,
162
145
  /**
163
- * Marker layout property object, that is passed to the MlImageMarkerLayer responsible for drawing the position marker.
164
- * Use any available layout property from layer type "symbol".
165
- * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#symbol
166
- */
167
- markerLayout: PropTypes.object,
168
- /**
169
- * Replace the default marker image with a custom one.
146
+ * position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
147
+ * Use any available paint prop from layer type "fill".
148
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
170
149
  */
171
- markerImage: PropTypes.string,
150
+ circlePaint: PropTypes.object,
172
151
  };
173
152
  export default MlFollowGps;
@@ -58,6 +58,6 @@ describe("<MlFollowGps>", () => {
58
58
  wrapper.find("MlFollowGps button").simulate("click");
59
59
  //wrapper.find(".toggle_layer_visible").simulate("click");
60
60
 
61
- await waitFor(() => expect(mockGeolocation.clearWatch).toHaveBeenCalledTimes(2));
61
+ await waitFor(() => expect(mockGeolocation.clearWatch).toHaveBeenCalledTimes(1));
62
62
  });
63
63
  });