@mapcomponents/react-maplibre 0.1.64 → 0.1.66

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 (134) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/coverage/clover.xml +20 -3
  3. package/coverage/coverage-final.json +2 -1
  4. package/coverage/lcov-report/index.html +24 -9
  5. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
  6. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  7. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
  8. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  10. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  11. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +1 -1
  12. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
  13. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
  15. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  16. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  17. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  18. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
  19. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  22. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +1 -1
  23. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +1 -1
  24. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +1 -1
  26. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +1 -1
  27. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +2 -2
  28. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
  29. package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +1 -1
  30. package/coverage/lcov-report/src/components/MlGpxViewer/index.html +1 -1
  31. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
  32. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  34. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  35. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
  36. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
  38. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  39. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  40. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  41. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  44. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  46. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  48. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
  50. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  53. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  54. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  55. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  56. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  57. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  58. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +1 -1
  59. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +1 -1
  60. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +1 -1
  61. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +1 -1
  62. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +1 -1
  63. package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +2 -2
  64. package/coverage/lcov-report/src/components/MlSketchTool/index.html +1 -1
  65. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +1 -1
  66. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  67. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  68. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  69. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  70. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  71. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  72. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  73. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
  74. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  75. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  76. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  77. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
  78. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  79. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +2 -2
  80. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  81. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
  82. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  83. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  84. package/coverage/lcov-report/src/contexts/index.html +1 -1
  85. package/coverage/lcov-report/src/hooks/index.html +1 -1
  86. package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
  87. package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
  88. package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
  89. package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
  90. package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
  91. package/coverage/lcov-report/src/hooks/useGpx/index.html +1 -1
  92. package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +1 -1
  93. package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
  94. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
  95. package/coverage/lcov-report/src/hooks/useLayerFilter/index.html +116 -0
  96. package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +184 -0
  97. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +1 -1
  98. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +1 -1
  99. package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
  100. package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
  101. package/coverage/lcov-report/src/hooks/useSource.ts.html +1 -1
  102. package/coverage/lcov-report/src/hooks/useWms.ts.html +1 -1
  103. package/coverage/lcov-report/src/index.html +1 -1
  104. package/coverage/lcov-report/src/index.ts.html +5 -2
  105. package/coverage/lcov.info +35 -0
  106. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -1
  107. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +12 -9
  108. package/dist/components/MlSketchTool/MlSketchTool.d.ts +1 -1
  109. package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +13 -9
  110. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +20 -15
  111. package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +20 -12
  112. package/dist/hooks/useLayerFilter/useLayerFilter.d.ts +8 -0
  113. package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +9 -0
  114. package/dist/index.d.ts +1 -0
  115. package/dist/index.esm.js +20 -1
  116. package/dist/index.esm.js.map +1 -1
  117. package/package.json +1 -1
  118. package/src/components/MlGeojsonLayerWithSource/{MlGeojsonLayerWithSource.stories.js → MlGeojsonLayerWithSource.stories.tsx} +0 -0
  119. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +1 -1
  120. package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +2 -2
  121. package/src/components/MlGpxViewer/util/MlGpxViewerInstructions.tsx +52 -49
  122. package/src/components/MlSketchTool/{MlSketchTool.stories.js → MlSketchTool.stories.tsx} +1 -1
  123. package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
  124. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.tsx +3 -3
  125. package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.tsx +37 -0
  126. package/src/components/MlWmsFeatureInfoPopup/{MlWmsFeatureInfoPopup.stories.js → MlWmsFeatureInfoPopup.stories.tsx} +5 -5
  127. package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -1
  128. package/src/hooks/useLayerFilter/useLayerFilter.doc.de.md +3 -0
  129. package/src/hooks/useLayerFilter/useLayerFilter.meta_.json +14 -0
  130. package/src/hooks/useLayerFilter/useLayerFilter.stories.tsx +40 -0
  131. package/src/hooks/useLayerFilter/useLayerFilter.ts +33 -0
  132. package/src/index.ts +1 -0
  133. package/src/components/MlLayer/MlLayer.stories.js +0 -20
  134. package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.js +0 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.64",
3
+ "version": "0.1.66",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.esm.js",
@@ -3,7 +3,7 @@ import useMap from "../../hooks/useMap";
3
3
  import useLayer from "../../hooks/useLayer";
4
4
  import useSource from "../../hooks/useSource";
5
5
 
6
- interface MlGeojsonLayerWithSourceProps {
6
+ export interface MlGeojsonLayerWithSourceProps {
7
7
  /**
8
8
  * Id of the target MapLibre instance in mapContext
9
9
  */
@@ -62,8 +62,8 @@ const Template = () => {
62
62
  <div
63
63
  style={{
64
64
  position: 'fixed',
65
- right: '5px',
66
- bottom: mediaIsMobile ? '40px' : '25px',
65
+ right: '11px',
66
+ bottom: mediaIsMobile ? '230px' : '145px',
67
67
  display: 'flex',
68
68
  flexDirection: 'column',
69
69
  gap: '5px',
@@ -1,68 +1,71 @@
1
1
  import React from 'react';
2
2
  import Instructions from '../../../util/Instructions';
3
+ import { useMediaQuery } from '@mui/material';
3
4
 
4
5
  const bubbleBottomRightStyle = {
5
6
  bubbleRight: '-120px',
6
- bubbleBottom: '-120px',
7
7
  textMarginTop: '70px',
8
8
  textMarginLeft: '120px',
9
9
  iconTransform: 'rotate(180deg)',
10
10
  iconMarginLeft: '200px',
11
- zIndex: 200
11
+ zIndex: 200,
12
12
  };
13
13
 
14
- const steps = [
15
- {
16
- duration: 3000,
17
- props: {
18
- ...bubbleBottomRightStyle,
19
- iconMarginTop: '43px',
20
- },
21
- content: (
22
- <>
23
- You can load your <br />
24
- own GPX file <br /> here
25
- </>
26
- ),
14
+ const getSteps = (mediaIsMobile:boolean) => [
15
+ {
16
+ duration: 3000,
17
+ props: {
18
+ ...bubbleBottomRightStyle,
19
+ iconMarginTop: '43px',
20
+ bubbleBottom: mediaIsMobile ? '90px' : 0,
27
21
  },
28
- {
29
- duration: 3000,
30
- props: {
31
- ...bubbleBottomRightStyle,
32
- iconMarginTop: '68px',
33
- },
34
- content: (
35
- <>
36
- You can see more <br /> information about <br />
37
- the track <br />
38
- here
39
- </>
40
- ),
22
+ content: (
23
+ <>
24
+ You can load your <br />
25
+ own GPX file <br /> here
26
+ </>
27
+ ),
28
+ },
29
+ {
30
+ duration: 3000,
31
+ props: {
32
+ ...bubbleBottomRightStyle,
33
+ iconMarginTop: '68px',
34
+ bubbleBottom: mediaIsMobile ? '90px' : 0,
41
35
  },
42
- {
43
- duration: 3000,
44
- props: {
45
- bubbleLeft: '-40px',
46
- bubbleTop: '-150px',
47
- textMarginTop: '230px',
48
- textMarginLeft: '75px',
49
- iconTransform: 'rotate(90deg)',
50
- iconMarginTop: '-135px',
51
- iconMarginLeft: '280px',
52
- zIndex: 400
53
- },
54
- content: (
55
- <>
56
- In demo mode we <br /> provide you some <br /> GPX tracks <br /> to load.
57
- </>
58
- ),
36
+ content: (
37
+ <>
38
+ You can see more <br /> information about <br />
39
+ the track <br />
40
+ here
41
+ </>
42
+ ),
43
+ },
44
+ {
45
+ duration: 3000,
46
+ props: {
47
+ bubbleLeft: '-40px',
48
+ bubbleTop: '-150px',
49
+ textMarginTop: '230px',
50
+ textMarginLeft: '75px',
51
+ iconTransform: 'rotate(90deg)',
52
+ iconMarginTop: '-135px',
53
+ iconMarginLeft: '280px',
54
+ zIndex: 400,
59
55
  },
60
- ];
61
- export default function MlGpxViewerInstructions(props: { open: boolean}) {
62
-
56
+ content: (
57
+ <>
58
+ In demo mode we <br /> provide you some <br /> GPX tracks <br /> to load.
59
+ </>
60
+ ),
61
+ },
62
+ ];
63
+ export default function MlGpxViewerInstructions(props: { open: boolean }) {
64
+ const mediaIsMobile = useMediaQuery('(max-width:900px)');
65
+
63
66
  return (
64
67
  <>
65
- <Instructions steps={steps} open={props.open} />
68
+ <Instructions steps={getSteps(mediaIsMobile)} open={props.open} />
66
69
  </>
67
70
  );
68
71
  }
@@ -13,7 +13,7 @@ const storyoptions = {
13
13
  };
14
14
  export default storyoptions;
15
15
 
16
- const Template = (args) => (
16
+ const Template = () => (
17
17
  <>
18
18
  <Sidebar sx={{ maxWidth: '25vw' }}>
19
19
  <MlSketchTool />
@@ -21,7 +21,7 @@ import { Feature } from '@turf/turf';
21
21
  import { LngLatLike } from '!maplibre-gl';
22
22
  import { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';
23
23
 
24
- interface MlSketchToolProps {
24
+ export interface MlSketchToolProps {
25
25
  /**
26
26
  * Id of the target MapLibre instance in mapContext
27
27
  */
@@ -59,8 +59,8 @@ const Template = () => {
59
59
 
60
60
  return (
61
61
  <>
62
- <TopToolbar>
63
62
  <MlGpxViewerInstructions open={guide} />
63
+ <TopToolbar appBarStyle={{ zIndex: 500 }}>
64
64
  <Button variant="contained" onClick={handleClick2} sx={{ marginRight: '10px' }}>
65
65
  Guide me through
66
66
  </Button>
@@ -73,8 +73,8 @@ const Template = () => {
73
73
  <div
74
74
  style={{
75
75
  position: 'fixed',
76
- right: '5px',
77
- bottom: mediaIsMobile ? '40px' : '25px',
76
+ right: '11px',
77
+ bottom: mediaIsMobile ? '230px' : '145px',
78
78
  display: 'flex',
79
79
  flexDirection: 'column',
80
80
  gap: '5px',
@@ -0,0 +1,37 @@
1
+ import React, { useContext } from 'react';
2
+
3
+ import TopToolbar from '../../ui_components/TopToolbar';
4
+ import MlThreeJsLayer from './MlThreeJsLayer';
5
+
6
+ import mapContextDecorator from '../../decorators/MapContextDecorator';
7
+ import { LoadingOverlayContext } from '../../ui_components/LoadingOverlayContext';
8
+
9
+ const storyoptions = {
10
+ title: 'MapComponents/MlThreeJsLayer',
11
+ component: MlThreeJsLayer,
12
+ argTypes: {
13
+ options: {
14
+ control: {
15
+ type: 'object',
16
+ },
17
+ },
18
+ },
19
+ decorators: mapContextDecorator,
20
+ };
21
+ export default storyoptions;
22
+
23
+ const Template = () => {
24
+ const loadingOverlayContext = useContext(LoadingOverlayContext);
25
+
26
+ return (
27
+ <TopToolbar>
28
+ <MlThreeJsLayer
29
+ init={() => loadingOverlayContext?.setControlled?.(true)}
30
+ onDone={() => setTimeout(() => loadingOverlayContext?.setLoadingDone?.(true), 1200)}
31
+ />
32
+ </TopToolbar>
33
+ );
34
+ };
35
+
36
+ export const ExampleConfig = Template.bind({});
37
+ ExampleConfig.parameters = {};
@@ -1,11 +1,11 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
 
3
- import MlWmsFeatureInfoPopup from "./MlWmsFeatureInfoPopup";
3
+ import MlWmsFeatureInfoPopup from './MlWmsFeatureInfoPopup';
4
4
 
5
- import mapContextDecorator from "../../decorators/MapContextDecorator";
5
+ import mapContextDecorator from '../../decorators/MapContextDecorator';
6
6
 
7
7
  const storyoptions = {
8
- title: "MapComponents/MlWmsFeatureInfoPopup",
8
+ title: 'MapComponents/MlWmsFeatureInfoPopup',
9
9
  component: MlWmsFeatureInfoPopup,
10
10
  argTypes: {
11
11
  url: {},
@@ -15,7 +15,7 @@ const storyoptions = {
15
15
  };
16
16
  export default storyoptions;
17
17
 
18
- const Template = (args) => <MlWmsFeatureInfoPopup />;
18
+ const Template = () => <MlWmsFeatureInfoPopup />;
19
19
 
20
20
  export const ExampleConfig = Template.bind({});
21
21
  ExampleConfig.parameters = {};
@@ -212,7 +212,7 @@ const MlWmsLoader = (props: MlWmsLoaderProps) => {
212
212
 
213
213
  // collect aueriable Layer2 layers
214
214
  let _layers: LayerType[] = capabilities?.Capability?.Layer?.Layer.filter(
215
- (el) => el.CRS.length
215
+ (el) => !el.Layer?.length
216
216
  ).map((layer: Layer2 & { Name: string }, idx: number) => {
217
217
  if (idx === 0) {
218
218
  _LatLonBoundingBox = layer.EX_GeographicBoundingBox;
@@ -0,0 +1,3 @@
1
+ # Component Beschreibung
2
+
3
+ Beschreibungstext
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "useLayerFilter",
3
+ "title": "",
4
+ "description": "",
5
+ "i18n": {
6
+ "de": {
7
+ "title": "",
8
+ "description": ""
9
+ }
10
+ },
11
+ "tags": [],
12
+ "category": "",
13
+ "type": "component"
14
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+
3
+ import useLayerFilter from './useLayerFilter';
4
+
5
+ import mapContextDecorator from '../../decorators/MapContextDecorator';
6
+ import MlGeoJsonLayer from '../../components/MlGeoJsonLayer/MlGeoJsonLayer';
7
+ import sample from '../../components/MlGeoJsonLayer/assets/sample_2.json';
8
+ import { FeatureCollection } from '@turf/turf';
9
+
10
+ const storyoptions = {
11
+ title: 'hooks/useLayerFilter',
12
+ component: useLayerFilter,
13
+ argTypes: {},
14
+ decorators: mapContextDecorator,
15
+ };
16
+ export default storyoptions;
17
+
18
+ const Template = (args: { filter_name: string }) => {
19
+ useLayerFilter({ layerId: 'filter_test', filter: ['==', 'name', args.filter_name] });
20
+ return <MlGeoJsonLayer layerId="filter_test" geojson={sample as FeatureCollection} />;
21
+ };
22
+
23
+ export const ExampleConfig = Template.bind({});
24
+ ExampleConfig.parameters = {};
25
+ ExampleConfig.args = {
26
+ filter_name: 'Mauspfad',
27
+ };
28
+ ExampleConfig.argTypes = {
29
+ filter_name: {
30
+ options: [
31
+ 'Mauspfad',
32
+ 'Windeckstraße',
33
+ 'Münsterplatz',
34
+ 'Postrstraße',
35
+ 'In der Sürst',
36
+ 'Remiglustraße',
37
+ ],
38
+ control: { type: 'radio' },
39
+ },
40
+ };
@@ -0,0 +1,33 @@
1
+ import { useEffect } from 'react';
2
+ import useMap from '../useMap';
3
+ import { FilterSpecification } from 'maplibre-gl';
4
+
5
+ export interface UseLayerFilterProps {
6
+ mapId?: string;
7
+ layerId?: string;
8
+ filter?: FilterSpecification;
9
+ }
10
+
11
+ function useLayerFilter(props: UseLayerFilterProps) {
12
+ const mapHook = useMap({ mapId: props.mapId });
13
+
14
+ useEffect(() => {
15
+ if (!mapHook.map || !props.layerId || !props.filter) return;
16
+
17
+ if (mapHook.map.map.getLayer(props.layerId)) {
18
+ const _layerId = props.layerId;
19
+
20
+ mapHook.map.map.setFilter(_layerId, props.filter);
21
+ return () => {
22
+ if (mapHook.map) {
23
+ mapHook.map.map.setFilter(_layerId, null);
24
+ }
25
+ };
26
+ }
27
+ return;
28
+ }, [props, mapHook.map]);
29
+
30
+ return {};
31
+ }
32
+
33
+ export default useLayerFilter;
package/src/index.ts CHANGED
@@ -38,6 +38,7 @@ export { default as useWms } from "./hooks/useWms";
38
38
  export { default as useSource } from "./hooks/useSource";
39
39
  export { default as useExportMap } from "./hooks/useExportMap";
40
40
  export { default as useCameraFollowPath } from "./hooks/useCameraFollowPath/useCameraFollowPath";
41
+ export { default as useLayerFilter } from "./hooks/useLayerFilter/useLayerFilter";
41
42
 
42
43
  export { MapComponentsProvider } from "./contexts/MapContext";
43
44
  export { default as MapContext } from "./contexts/MapContext";
@@ -1,20 +0,0 @@
1
- import React from "react";
2
-
3
- import MlLayer from "./MlLayer";
4
-
5
- import mapContextDecorator from "../../decorators/MapContextDecorator";
6
-
7
- const storyoptions = {
8
- title: "MapComponents/MlLayer",
9
- component: MlLayer,
10
- argTypes: {
11
- },
12
- decorators: mapContextDecorator,
13
- };
14
- export default storyoptions;
15
-
16
- const Template = (args) => <MlLayer />;
17
-
18
- export const ExampleConfig = Template.bind({});
19
- ExampleConfig.parameters = {};
20
- ExampleConfig.args = {};
@@ -1,39 +0,0 @@
1
- import React, { useContext } from "react";
2
-
3
- import TopToolbar from "../../ui_components/TopToolbar";
4
- import MlThreeJsLayer from "./MlThreeJsLayer";
5
-
6
- import mapContextDecorator from "../../decorators/MapContextDecorator";
7
- import { LoadingOverlayContext } from "../../ui_components/LoadingOverlayContext";
8
-
9
- const storyoptions = {
10
- title: "MapComponents/MlThreeJsLayer",
11
- component: MlThreeJsLayer,
12
- argTypes: {
13
- options: {
14
- control: {
15
- type: "object",
16
- },
17
- },
18
- },
19
- decorators: mapContextDecorator,
20
- };
21
- export default storyoptions;
22
-
23
- const Template = (args) => {
24
- const loadingOverlayContext = useContext(LoadingOverlayContext);
25
-
26
- return (
27
- <TopToolbar>
28
- <MlThreeJsLayer
29
- init={() => loadingOverlayContext?.setControlled?.(true)}
30
- onDone={() =>
31
- setTimeout(() => loadingOverlayContext?.setLoadingDone?.(true), 1200)
32
- }
33
- />
34
- </TopToolbar>
35
- );
36
- };
37
-
38
- export const ExampleConfig = Template.bind({});
39
- ExampleConfig.parameters = {};