@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.
- package/CHANGELOG.md +15 -0
- package/coverage/clover.xml +20 -3
- package/coverage/coverage-final.json +2 -1
- package/coverage/lcov-report/index.html +24 -9
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGpxViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlSketchTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useGpx/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerFilter/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +184 -0
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useSource.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useWms.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +5 -2
- package/coverage/lcov.info +35 -0
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +12 -9
- package/dist/components/MlSketchTool/MlSketchTool.d.ts +1 -1
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +13 -9
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +20 -15
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +20 -12
- package/dist/hooks/useLayerFilter/useLayerFilter.d.ts +8 -0
- package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +20 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MlGeojsonLayerWithSource/{MlGeojsonLayerWithSource.stories.js → MlGeojsonLayerWithSource.stories.tsx} +0 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +1 -1
- package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +2 -2
- package/src/components/MlGpxViewer/util/MlGpxViewerInstructions.tsx +52 -49
- package/src/components/MlSketchTool/{MlSketchTool.stories.js → MlSketchTool.stories.tsx} +1 -1
- package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.tsx +3 -3
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.tsx +37 -0
- package/src/components/MlWmsFeatureInfoPopup/{MlWmsFeatureInfoPopup.stories.js → MlWmsFeatureInfoPopup.stories.tsx} +5 -5
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -1
- package/src/hooks/useLayerFilter/useLayerFilter.doc.de.md +3 -0
- package/src/hooks/useLayerFilter/useLayerFilter.meta_.json +14 -0
- package/src/hooks/useLayerFilter/useLayerFilter.stories.tsx +40 -0
- package/src/hooks/useLayerFilter/useLayerFilter.ts +33 -0
- package/src/index.ts +1 -0
- package/src/components/MlLayer/MlLayer.stories.js +0 -20
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.js +0 -39
package/package.json
CHANGED
|
File without changes
|
|
@@ -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
|
*/
|
|
@@ -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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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={
|
|
68
|
+
<Instructions steps={getSteps(mediaIsMobile)} open={props.open} />
|
|
66
69
|
</>
|
|
67
70
|
);
|
|
68
71
|
}
|
|
@@ -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: '
|
|
77
|
-
bottom: mediaIsMobile ? '
|
|
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
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import MlWmsFeatureInfoPopup from
|
|
3
|
+
import MlWmsFeatureInfoPopup from './MlWmsFeatureInfoPopup';
|
|
4
4
|
|
|
5
|
-
import mapContextDecorator from
|
|
5
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
6
6
|
|
|
7
7
|
const storyoptions = {
|
|
8
|
-
title:
|
|
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 = (
|
|
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.
|
|
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,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 = {};
|