@mapcomponents/react-maplibre 1.0.9 → 1.0.11

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 (37) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.cjs.js +125 -69
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +125 -69
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/src/components/MlClientSearch/lib/createGeojsonFeature.d.ts +3 -2
  7. package/dist/src/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -1
  8. package/dist/src/components/MlCreatePdfForm/lib/PdfPreview.d.ts +1 -1
  9. package/dist/src/components/MlCreatePngButton/MlCreatePngButton.d.ts +1 -1
  10. package/dist/src/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +2 -2
  11. package/dist/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.d.ts +2 -1
  12. package/dist/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.d.ts +3 -1
  13. package/dist/src/components/MlGpxViewer/MlGpxViewer.d.ts +1 -1
  14. package/dist/src/components/MlGpxViewer/util/GeoJsonContext.d.ts +3 -3
  15. package/dist/src/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +1 -1
  16. package/dist/src/components/MlLayer/MlLayer.d.ts +1 -1
  17. package/dist/src/components/MlMeasureTool/MlMeasureTool.d.ts +8 -7
  18. package/dist/src/components/MlMultiMeasureTool/MlMultiMeasureTool.d.ts +3 -3
  19. package/dist/src/components/MlSketchTool/MlSketchTool.d.ts +1 -1
  20. package/dist/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +1 -1
  21. package/dist/src/components/MlSpatialElevationProfile/util/getElevationData.d.ts +1 -1
  22. package/dist/src/components/MlTemporalController/MlTemporalController.d.ts +1 -1
  23. package/dist/src/components/MlTemporalController/utils/MlTemporalControllerLabels.d.ts +1 -1
  24. package/dist/src/components/MlTemporalController/utils/useFilterData.d.ts +2 -2
  25. package/dist/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +2 -2
  26. package/dist/src/hooks/useExportMap/lib.d.ts +1 -1
  27. package/dist/src/hooks/useFeatureEditor/useFeatureEditor.d.ts +3 -3
  28. package/dist/src/hooks/useFeatureEditor/utils/FeatureEditorStyle.d.ts +44 -16
  29. package/dist/src/hooks/useGpx/useGpx.d.ts +2 -2
  30. package/dist/src/hooks/useLayer.d.ts +3 -3
  31. package/dist/src/hooks/useLayerHoverPopup/LayerHoverPopup.d.ts +2 -1
  32. package/dist/src/protocol_handlers/csv.d.ts +2 -2
  33. package/dist/src/protocol_handlers/osm.d.ts +2 -2
  34. package/dist/src/protocol_handlers/topojson.d.ts +2 -2
  35. package/dist/src/protocol_handlers/xml.d.ts +2 -2
  36. package/package.json +6 -4
  37. package/rollup.config.mjs +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.0.11] - 2025-02-14
4
+
5
+ ### Fixed
6
+
7
+ - fix package.json `types` property value in release
8
+
9
+ ## [v1.0.10] - 2025-02-13
10
+
11
+ ### Added
12
+
13
+ - 3a5b6ca: add cypress test-setup
14
+ - 4e346a2: add MlOgcApiFeatures components
15
+
16
+ ### Changed
17
+
18
+ - a6ab82d: use @types/geojson throughout the whole project, replace turf geojson types
19
+ - 3c16c31: improve MlFeatureEditor demo UX
20
+
3
21
  ## [v1.0.9] - 2024-11-20
4
22
 
5
23
  ### Added
package/dist/index.cjs.js CHANGED
@@ -2031,9 +2031,9 @@ function featureEditorStyle() {
2031
2031
  ['!=', 'mode', 'static'],
2032
2032
  ],
2033
2033
  paint: {
2034
- 'fill-color': '#3bb2d0',
2035
- 'fill-outline-color': '#3bb2d0',
2036
- 'fill-opacity': 0.1,
2034
+ 'fill-color': '#009EE0',
2035
+ 'fill-outline-color': '#009EE0',
2036
+ 'fill-opacity': 0.3,
2037
2037
  },
2038
2038
  },
2039
2039
  {
@@ -2041,18 +2041,9 @@ function featureEditorStyle() {
2041
2041
  type: 'fill',
2042
2042
  filter: ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']],
2043
2043
  paint: {
2044
- 'fill-color': '#fbb03b',
2045
- 'fill-outline-color': '#fbb03b',
2046
- 'fill-opacity': 0.1,
2047
- },
2048
- },
2049
- {
2050
- id: 'gl-draw-polygon-midpoint',
2051
- type: 'circle',
2052
- filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint']],
2053
- paint: {
2054
- 'circle-radius': mediaIsMobile ? 7 : 5,
2055
- 'circle-color': '#fbb03b',
2044
+ 'fill-color': '#009EE0',
2045
+ 'fill-outline-color': '#009EE0',
2046
+ 'fill-opacity': 0.2,
2056
2047
  },
2057
2048
  },
2058
2049
  {
@@ -2069,8 +2060,8 @@ function featureEditorStyle() {
2069
2060
  'line-join': 'round',
2070
2061
  },
2071
2062
  paint: {
2072
- 'line-color': '#3bb2d0',
2073
- 'line-width': 2,
2063
+ 'line-color': '#009EE0',
2064
+ 'line-width': 3,
2074
2065
  },
2075
2066
  },
2076
2067
  {
@@ -2082,7 +2073,7 @@ function featureEditorStyle() {
2082
2073
  'line-join': 'round',
2083
2074
  },
2084
2075
  paint: {
2085
- 'line-color': '#fbb03b',
2076
+ 'line-color': '#009EE0',
2086
2077
  'line-dasharray': [0.2, 2],
2087
2078
  'line-width': 2,
2088
2079
  },
@@ -2101,8 +2092,8 @@ function featureEditorStyle() {
2101
2092
  'line-join': 'round',
2102
2093
  },
2103
2094
  paint: {
2104
- 'line-color': '#3bb2d0',
2105
- 'line-width': 2,
2095
+ 'line-color': '#009EE0',
2096
+ 'line-width': 3,
2106
2097
  },
2107
2098
  },
2108
2099
  {
@@ -2114,11 +2105,22 @@ function featureEditorStyle() {
2114
2105
  'line-join': 'round',
2115
2106
  },
2116
2107
  paint: {
2117
- 'line-color': '#fbb03b',
2108
+ 'line-color': "#009EE0",
2118
2109
  'line-dasharray': [0.2, 2],
2119
2110
  'line-width': 2,
2120
2111
  },
2121
2112
  },
2113
+ {
2114
+ id: 'gl-draw-polygon-midpoint',
2115
+ type: 'circle',
2116
+ filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint']],
2117
+ paint: {
2118
+ 'circle-radius': mediaIsMobile ? 5 : 4,
2119
+ 'circle-color': '#ffffff',
2120
+ 'circle-stroke-color': '#009EE0',
2121
+ 'circle-stroke-width': 1
2122
+ },
2123
+ },
2122
2124
  {
2123
2125
  id: 'gl-draw-polygon-and-line-vertex-stroke-inactive',
2124
2126
  type: 'circle',
@@ -2134,7 +2136,9 @@ function featureEditorStyle() {
2134
2136
  filter: ['all', ['==', 'meta', 'vertex'], ['==', '$type', 'Point'], ['!=', 'mode', 'static']],
2135
2137
  paint: {
2136
2138
  'circle-radius': mediaIsMobile ? 7 : 5,
2137
- 'circle-color': '#fbb03b',
2139
+ 'circle-color': '#ffffff',
2140
+ 'circle-stroke-color': '#009EE0',
2141
+ 'circle-stroke-width': 1
2138
2142
  },
2139
2143
  },
2140
2144
  {
@@ -2150,7 +2154,7 @@ function featureEditorStyle() {
2150
2154
  paint: {
2151
2155
  'circle-radius': mediaIsMobile ? 10 : 9,
2152
2156
  'circle-opacity': 1,
2153
- 'circle-color': '#fff',
2157
+ 'circle-color': '#009EE0',
2154
2158
  },
2155
2159
  },
2156
2160
  {
@@ -2165,7 +2169,7 @@ function featureEditorStyle() {
2165
2169
  ],
2166
2170
  paint: {
2167
2171
  'circle-radius': mediaIsMobile ? 7.5 : 6.5,
2168
- 'circle-color': '#3bb2d0',
2172
+ 'circle-color': '#009EE0',
2169
2173
  },
2170
2174
  },
2171
2175
  {
@@ -2193,7 +2197,7 @@ function featureEditorStyle() {
2193
2197
  ],
2194
2198
  paint: {
2195
2199
  'circle-radius': mediaIsMobile ? 8.5 : 7.5,
2196
- 'circle-color': '#fbb03b',
2200
+ 'circle-color': '#009EE0',
2197
2201
  },
2198
2202
  },
2199
2203
  {
@@ -2932,7 +2936,7 @@ var MlFollowGps = function (props) {
2932
2936
  ];
2933
2937
  var accurancyBounds = turf.bbox(accuracyGeoJson);
2934
2938
  var contained = turf.booleanContains(turf.bboxPolygon(actualBounds), turf.bboxPolygon(accurancyBounds));
2935
- if (contained === false) {
2939
+ if (!contained) {
2936
2940
  (_b = mapHook.map) === null || _b === void 0 ? void 0 : _b.fitBounds(accurancyBounds, {
2937
2941
  padding: { top: 25, bottom: 25 },
2938
2942
  });
@@ -3011,46 +3015,93 @@ var MlImageMarkerLayer = function (props) {
3011
3015
  return React.createElement(React.Fragment, null);
3012
3016
  };
3013
3017
 
3014
- //const unitSquareConvert = {
3015
- // kilometers: 1,
3016
- // miles: 1 / 2.58998811,
3017
- //};
3018
- function getUnitSquareMultiplier(measureType) {
3019
- return measureType === 'miles' ? 1 / 2.58998811 : 1;
3018
+ function unitMultiplier(unit) {
3019
+ switch (unit) {
3020
+ case 'meters':
3021
+ return 1;
3022
+ case 'millimeters':
3023
+ return 1000;
3024
+ case 'centimeters':
3025
+ return 100;
3026
+ case 'kilometers':
3027
+ return 0.001;
3028
+ case 'miles':
3029
+ return 1 / 1609.344; // Meters in Miles
3030
+ case 'nauticalmiles':
3031
+ return 1 / 1852; // Meters in Nautical Miles
3032
+ case 'inches':
3033
+ return 39.3701; // Meters in Inches
3034
+ case 'yards':
3035
+ return 1.09361; // Meters in Yards
3036
+ case 'feet':
3037
+ return 3.28084; // Meters in Feet
3038
+ // case 'acres':
3039
+ // return 1 / 4046.8564224; // Square meters in an acre
3040
+ // case 'hectares':
3041
+ // return 1 / 10000; // Square meters in a hectare
3042
+ default:
3043
+ return 1;
3044
+ }
3020
3045
  }
3021
- function getUnitLabel(measureType) {
3022
- return measureType === 'miles' ? 'mi' : 'km';
3046
+ function unitLabel(unit) {
3047
+ switch (unit) {
3048
+ case 'miles':
3049
+ return 'mi';
3050
+ case 'acres':
3051
+ return 'ac';
3052
+ case 'kilometers':
3053
+ return 'km';
3054
+ case 'meters':
3055
+ return 'm';
3056
+ case 'millimeters':
3057
+ return 'mm';
3058
+ case 'centimeters':
3059
+ return 'cm';
3060
+ case 'nauticalmiles':
3061
+ return 'nm';
3062
+ case 'inches':
3063
+ return 'in';
3064
+ case 'yards':
3065
+ return 'yd';
3066
+ case 'feet':
3067
+ return 'ft';
3068
+ case 'hectares':
3069
+ return 'ha';
3070
+ default:
3071
+ return 'm';
3072
+ }
3023
3073
  }
3024
3074
  var MlMeasureTool = function (props) {
3025
3075
  var _a = React.useState({ value: 0, label: '' }), displayValue = _a[0], setDisplayValue = _a[1];
3026
3076
  var _b = React.useState([]), currentFeatures = _b[0], setCurrentFeatures = _b[1];
3027
3077
  React.useEffect(function () {
3028
3078
  if (currentFeatures[0]) {
3029
- var result = props.measureType === 'polygon'
3030
- ? // for "polyong" mode calculate km²
3031
- (turf__namespace.area(currentFeatures[0]) / 1000000) *
3032
- getUnitSquareMultiplier(props.unit)
3033
- : turf__namespace.length(currentFeatures[0], { units: props.unit });
3079
+ var result = 0;
3080
+ if (props.measureType === 'polygon') {
3081
+ // Calculate area in square meters
3082
+ result = turf__namespace.area(currentFeatures[0]);
3083
+ // Convert area depending on the unit (square meters -> selected area unit)
3084
+ if (props.unit) {
3085
+ var unit = props.unit;
3086
+ if (unit === 'acres') {
3087
+ result = result / 4046.8564224;
3088
+ }
3089
+ else if (unit === 'hectares') {
3090
+ result = result / 10000;
3091
+ }
3092
+ else {
3093
+ result = result * Math.pow(unitMultiplier(props.unit), 2);
3094
+ }
3095
+ }
3096
+ }
3097
+ else {
3098
+ result = turf__namespace.length(currentFeatures[0], { units: props.unit });
3099
+ }
3034
3100
  if (typeof props.onChange === 'function') {
3035
3101
  props.onChange({ value: result, unit: props.unit, geojson: currentFeatures[0] });
3036
3102
  }
3037
3103
  if (result >= 0.1) {
3038
- setDisplayValue({ value: result, label: getUnitLabel(props.unit) });
3039
- }
3040
- else {
3041
- var label = 'm';
3042
- var value = result * 1000;
3043
- if (props.measureType === 'polygon') {
3044
- value = result * 1000000;
3045
- }
3046
- if (getUnitLabel(props.unit) === 'mi') {
3047
- label = 'Yard';
3048
- value = result * 1760;
3049
- if (props.measureType === 'polygon') {
3050
- value = result * 3097600;
3051
- }
3052
- }
3053
- setDisplayValue({ value: value, label: label });
3104
+ setDisplayValue({ value: result, label: unitLabel(props.unit) });
3054
3105
  }
3055
3106
  }
3056
3107
  }, [props.unit, currentFeatures]);
@@ -3058,16 +3109,22 @@ var MlMeasureTool = function (props) {
3058
3109
  React.createElement(MlFeatureEditor, { onChange: function (features) {
3059
3110
  features && setCurrentFeatures(features);
3060
3111
  }, mode: props.measureType === 'polygon' ? 'draw_polygon' : 'draw_line_string', onFinish: props.onFinish }),
3061
- displayValue.value.toFixed(2),
3062
- " ",
3063
- '',
3064
- displayValue.label,
3065
- displayValue.label && props.measureType === 'polygon' ? ' ²' : ''));
3112
+ displayValue.value.toLocaleString('de-DE', {
3113
+ minimumFractionDigits: 2,
3114
+ maximumFractionDigits: 2,
3115
+ }),
3116
+ ' ',
3117
+ unitLabel(props.unit),
3118
+ displayValue.label &&
3119
+ props.measureType === 'polygon' &&
3120
+ !['hectares', 'acres'].includes(props.unit || '')
3121
+ ? ' ²'
3122
+ : ''));
3066
3123
  };
3067
3124
  MlMeasureTool.defaultProps = {
3068
3125
  mapId: undefined,
3069
3126
  measureType: 'line',
3070
- unit: 'kilometers',
3127
+ unit: 'meters',
3071
3128
  };
3072
3129
 
3073
3130
  var ListStyled$3 = material.styled(material.List)({
@@ -3624,7 +3681,6 @@ var MlMultiMeasureTool = function (props) {
3624
3681
  var _d = React.useState(), measureState = _d[0], setMeasureState = _d[1];
3625
3682
  var _e = React.useState('kilometers'), selectedUnit = _e[0], setSelectedUnit = _e[1];
3626
3683
  var _f = React.useState([]), measureList = _f[0], setMeasureList = _f[1];
3627
- console.log(measureList);
3628
3684
  var _g = React.useState(false), reload = _g[0], setReload = _g[1];
3629
3685
  var unitSwitch = function () {
3630
3686
  if (selectedUnit === 'kilometers') {
@@ -3973,7 +4029,7 @@ var MlNavigationTools = function (props) {
3973
4029
  var targetPitch = mapHook.map.getPitch() !== 0 ? 0 : 60;
3974
4030
  mapHook.map.easeTo({ pitch: targetPitch });
3975
4031
  }, [mapHook.map]);
3976
- return (React.createElement(Box, { sx: __assign(__assign({ zIndex: 501, position: 'absolute', display: 'flex', flexDirection: 'column', right: mediaIsMobile ? '15px' : '25px', bottom: mediaIsMobile ? '20px' : '30px' }, (mediaIsMobile ? { margin: '80px 10px 50px 10px' } : { marginTop: '50px' })), props.sx) },
4032
+ return (React.createElement(Box, { sx: __assign(__assign({ zIndex: 501, position: 'absolute', display: 'flex', flexDirection: 'column', right: mediaIsMobile ? '15px' : '25px', bottom: mediaIsMobile ? '20px' : '40px' }, (mediaIsMobile ? { margin: '80px 10px 50px 10px' } : { marginTop: '50px' })), props.sx) },
3977
4033
  React.createElement(MlNavigationCompass, null),
3978
4034
  props.show3DButton && (React.createElement(Button, { variant: "navtools", onClick: adjustPitch }, pitch < 29 ? '3D' : '2D')),
3979
4035
  props.showFollowGpsButton && React.createElement(MlFollowGps, null),
@@ -6218,13 +6274,13 @@ var MlWmsLoader = function (props) {
6218
6274
  var unprojected = mapHook.map.unproject([ev.point.x, ev.point.y]);
6219
6275
  var point = turf__namespace.point([unprojected.lng, unprojected.lat]);
6220
6276
  var buffered = turf__namespace.buffer(point, 50, { units: 'meters' });
6221
- var _bbox = turf__namespace.bbox(buffered);
6222
- var _sw = lngLatToMeters({ lng: _bbox[0], lat: _bbox[1] });
6223
- var _ne = lngLatToMeters({ lng: _bbox[2], lat: _bbox[3] });
6224
- var bbox = [_sw[0], _sw[1], _ne[0], _ne[1]];
6277
+ var _bbox = buffered && turf__namespace.bbox(buffered);
6278
+ var _sw = _bbox && lngLatToMeters({ lng: _bbox[0], lat: _bbox[1] });
6279
+ var _ne = _bbox && lngLatToMeters({ lng: _bbox[2], lat: _bbox[3] });
6280
+ var bbox = _sw && _ne && [_sw[0], _sw[1], _ne[0], _ne[1]];
6225
6281
  var _getFeatureInfoUrlParams = {
6226
6282
  REQUEST: 'GetFeatureInfo',
6227
- BBOX: bbox.join(','),
6283
+ BBOX: bbox === null || bbox === void 0 ? void 0 : bbox.join(','),
6228
6284
  SERVICE: 'WMS',
6229
6285
  INFO_FORMAT: ((_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _a === void 0 ? void 0 : _a.Request) === null || _b === void 0 ? void 0 : _b.GetFeatureInfo.Format.indexOf('text/html')) !== -1
6230
6286
  ? 'text/html'
@@ -7144,7 +7200,7 @@ var useCameraFollowPath = function (props) {
7144
7200
  var speed = React.useRef(props.speed);
7145
7201
  var timeoutId = React.useRef();
7146
7202
  var kmPerStep = props.kmPerStep || 0.01;
7147
- var routeDistance = turf__namespace.lineDistance(props.route);
7203
+ var routeDistance = turf__namespace.length(props.route);
7148
7204
  var stepDuration = props.stepDuration || 70;
7149
7205
  var mapHook = useMap({
7150
7206
  mapId: props.mapId,