@mapcomponents/react-maplibre 0.1.67 → 0.1.68
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/coverage/clover.xml +172 -174
- package/coverage/coverage-final.json +7 -7
- package/coverage/lcov-report/index.html +38 -38
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +43 -25
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +10 -10
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +30 -51
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +3 -3
- 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 +41 -98
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
- 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 +1 -1
- 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 +41 -113
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +15 -15
- 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.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.tsx.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 +2 -2
- 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/MlThreejsLayer.tsx.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 +22 -10
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +13 -13
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +24 -3
- 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 +2 -2
- 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 +1 -1
- package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +1 -1
- 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 +27 -3
- package/coverage/lcov.info +326 -342
- package/dist/components/MapLibreMap/MapLibreMap.d.ts +3 -3
- package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +2 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +1 -1
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +2 -15
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +1 -14
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -0
- package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +1 -0
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -0
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/_PdfPreview.d.ts +1 -0
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +1 -0
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +1 -0
- package/dist/components/MlFollowGps/MlFollowGps.d.ts +5 -23
- package/dist/components/MlFollowGps/MlFollowGps.stories.d.ts +2 -2
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +4 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -0
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +1 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +1 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +1 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +1 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +1 -0
- package/dist/components/MlLayer/MlLayer.d.ts +1 -0
- package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +1 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +1 -0
- package/dist/components/MlMarker/MlMarker.d.ts +1 -0
- package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +1 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.d.ts +1 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +5 -0
- package/dist/components/MlScaleReference/MlScaleReference.d.ts +1 -0
- package/dist/components/MlShareMapState/MlShareMapState.d.ts +1 -0
- package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +1 -0
- package/dist/components/MlSketchTool/MlSketchTool.d.ts +1 -0
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +1 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +1 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +1 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +1 -0
- package/dist/components/MlThreeJsLayer/MlThreejsLayer.d.ts +1 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +1 -0
- package/dist/components/MlVectorTileLayer/MlVectorTileLayer.d.ts +3 -2
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +1 -0
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +1 -0
- package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +1 -0
- package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +1 -0
- package/dist/decorators/EmptyMapDecorator.d.ts +2 -0
- package/dist/decorators/ThemeDecorator.d.ts +2 -0
- package/dist/hooks/useCameraFollowPath/useCameraFollowPath.stories.d.ts +1 -0
- package/dist/hooks/useExportMap/lib.d.ts +1 -1
- package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +1 -0
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.css +0 -97
- package/dist/index.esm.js +5495 -14503
- package/dist/index.esm.js.map +1 -1
- package/dist/ui_components/Dropzone.d.ts +1 -0
- package/dist/ui_components/ImageLoader.d.ts +1 -0
- package/dist/ui_components/LayerList/LayerList.d.ts +6 -0
- package/dist/ui_components/LayerList/LayerList.stories.d.ts +12 -0
- package/dist/ui_components/LayerList/LayerListFolder.d.ts +9 -0
- package/dist/ui_components/LayerList/LayerListItem.d.ts +18 -0
- package/dist/ui_components/LayerList/util/LayerListItemVectorLayer.d.ts +15 -0
- package/dist/ui_components/LayerList/util/LayerPropertyForm.d.ts +10 -0
- package/dist/ui_components/LayerList/util/input/ColorPicker.d.ts +10 -0
- package/dist/ui_components/LoadingOverlayContext.d.ts +0 -1
- package/dist/ui_components/MapcomponentsTheme.d.ts +7 -0
- package/dist/ui_components/Tooltip.d.ts +1 -0
- package/dist/ui_components/TopToolbar.d.ts +1 -0
- package/dist/ui_components/UploadButton.d.ts +1 -0
- package/dist/util/Instructions.d.ts +1 -0
- package/package.json +24 -31
- package/rollup.config.js +61 -44
- package/src/@types/assets/index.d.ts +1 -1
- package/src/App.css +0 -55
- package/src/components/MapLibreMap/MapLibreMap.stories.js +36 -37
- package/src/components/MapLibreMap/MapLibreMap.tsx +23 -17
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +1 -1
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +22 -29
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +6 -6
- package/src/components/MlFollowGps/MlFollowGps.stories.js +28 -10
- package/src/components/MlFollowGps/MlFollowGps.tsx +31 -50
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +1 -1
- package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +16 -10
- package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +4 -13
- package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +3 -1
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +4 -5
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +30 -54
- package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +1 -1
- package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +7 -3
- package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +3 -11
- package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +2 -2
- package/src/components/MlWmsLoader/utils/WMSLinks.tsx +1 -1
- package/src/contexts/MapContext.tsx +8 -1
- package/src/custom.d.ts +4 -5
- package/src/decorators/EmptyMapDecorator.js +38 -0
- package/src/decorators/MapContextDecorator.js +10 -16
- package/src/decorators/MapContextDecoratorHooks.js +25 -30
- package/src/decorators/MultiMapContextDecorator.js +8 -18
- package/src/decorators/NoNavToolsDecorator.js +8 -15
- package/src/decorators/ThemeDecorator.js +24 -0
- package/src/decorators/style.css +0 -2
- package/src/hooks/useCameraFollowPath/useCameraFollowPath.stories.tsx +13 -19
- package/src/hooks/useExportMap/lib.ts +1 -1
- package/src/hooks/useGpx/useGpx.stories.js +1 -1
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +1 -1
- package/src/hooks/useMapState.stories.js +1 -1
- package/src/hooks/useSources.stories.js +1 -1
- package/src/index.ts +9 -0
- package/src/ui_components/LayerList/LayerList.stories.tsx +136 -0
- package/src/ui_components/LayerList/LayerList.tsx +12 -0
- package/src/ui_components/LayerList/LayerListFolder.tsx +82 -0
- package/src/ui_components/LayerList/LayerListItem.tsx +180 -0
- package/src/ui_components/LayerList/assets/sample_1.json +26 -0
- package/src/ui_components/LayerList/assets/sample_2.json +22 -0
- package/src/ui_components/LayerList/assets/sample_polygon_1.json +33 -0
- package/src/ui_components/LayerList/assets/style.json +2599 -0
- package/src/ui_components/LayerList/util/LayerListItemVectorLayer.tsx +92 -0
- package/src/ui_components/LayerList/util/LayerPropertyForm.tsx +125 -0
- package/src/ui_components/LayerList/util/input/ColorPicker.tsx +44 -0
- package/src/ui_components/MapcomponentsTheme.tsx +133 -0
- package/src/ui_components/Sidebar.tsx +16 -11
- package/src/ui_components/TopToolbar.tsx +1 -3
- package/src/util/BubbleForInstructions.js +14 -12
- package/tsconfig.json +3 -10
- package/dist/components/MlGPXViewer/MlGPXViewer.d.ts +0 -29
- package/dist/components/MlGPXViewer/MlGPXViewer.stories.d.ts +0 -16
- package/dist/components/MlGPXViewer/MlGPXViewer.test.d.ts +0 -1
- package/dist/components/MlGPXViewer/gpxConverter.d.ts +0 -11
- package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +0 -10
- package/dist/components/MlGPXViewer/util/GeoJsonProvider.d.ts +0 -4
- package/dist/components/MlLayer/MlLayer.stories.d.ts +0 -10
- package/dist/custom.d.d.ts +0 -22
- package/dist/decorators/ThemeWrapper.d.ts +0 -1
- package/dist/hooks/exportMap/index.d.ts +0 -11
- package/dist/hooks/exportMap/lib.d.ts +0 -36
- package/dist/ui_components/Legend.d.ts +0 -1
- package/dist/ui_components/LoadingOverlay.d.ts +0 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import LayerList from './LayerList';
|
|
3
|
+
declare const storyoptions: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof LayerList;
|
|
6
|
+
argTypes: {};
|
|
7
|
+
decorators: ((Story: any, context: any) => JSX.Element)[];
|
|
8
|
+
};
|
|
9
|
+
export default storyoptions;
|
|
10
|
+
export declare const ExampleConfig: any;
|
|
11
|
+
export declare const FolderExample: any;
|
|
12
|
+
export declare const VectortileExample: any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
name?: string;
|
|
5
|
+
children: JSX.Element | JSX.Element[];
|
|
6
|
+
setVisible?: (visible: boolean | ((val: unknown) => boolean)) => void;
|
|
7
|
+
};
|
|
8
|
+
export default function LayerListFolder({ visible, name, children, setVisible }: Props): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
layerComponent: JSX.Element;
|
|
4
|
+
visible: boolean;
|
|
5
|
+
configurable: boolean;
|
|
6
|
+
type?: 'background' | 'background-labels' | 'layer' | 'wms-layer' | 'vector-tile-layer';
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
setLayerState?: (state: unknown) => void;
|
|
10
|
+
};
|
|
11
|
+
declare function LayerListItem({ layerComponent, visible, type, name, description, configurable, setLayerState, }: Props): JSX.Element;
|
|
12
|
+
declare namespace LayerListItem {
|
|
13
|
+
var defaultProps: {
|
|
14
|
+
type: string;
|
|
15
|
+
visible: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export default LayerListItem;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MlVectorTileLayerProps } from '../../../components/MlVectorTileLayer/MlVectorTileLayer';
|
|
3
|
+
type Props = {
|
|
4
|
+
id: string;
|
|
5
|
+
configurable?: boolean;
|
|
6
|
+
vtProps: MlVectorTileLayerProps;
|
|
7
|
+
setVtProps: ((state: unknown) => void) | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare function LayerListItemVectorLayer({ configurable, vtProps, setVtProps, id }: Props): JSX.Element;
|
|
10
|
+
declare namespace LayerListItemVectorLayer {
|
|
11
|
+
var defaultProps: {
|
|
12
|
+
configurable: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default LayerListItemVectorLayer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification } from 'maplibre-gl';
|
|
3
|
+
export type paintPropsType = CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['paint'];
|
|
4
|
+
type Props = {
|
|
5
|
+
paintProps: paintPropsType;
|
|
6
|
+
setPaintProps: (paintProps: paintPropsType | ((current: paintPropsType) => paintPropsType)) => void;
|
|
7
|
+
layerType: string;
|
|
8
|
+
};
|
|
9
|
+
export default function LayerPropertyForm({ paintProps, setPaintProps }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { paintPropsType } from '../LayerPropertyForm';
|
|
3
|
+
type Props = {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
propKey: string;
|
|
7
|
+
setPaintProps: (paintProps: paintPropsType | ((current: paintPropsType) => paintPropsType)) => void;
|
|
8
|
+
};
|
|
9
|
+
export default function PaintPropsColorPicker({ propKey, value, setPaintProps }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { JsxChildren } from 'typedoc/dist/lib/utils/jsx.elements';
|
|
4
3
|
declare const LoadingOverlayContext: React.Context<{}>;
|
|
5
4
|
declare const LoadingOverlayProvider: {
|
|
6
5
|
(children: JsxChildren): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/react-maplibre",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.68",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -19,7 +19,13 @@
|
|
|
19
19
|
"build-catalogue-markdown-docs": "node scripts/build-catalogue-markdown-docs.js",
|
|
20
20
|
"create-component": "./scripts/create-map-component.sh"
|
|
21
21
|
},
|
|
22
|
-
"dependencies": {
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"peerDependencies": {},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@babel/preset-react": "^7.18.6",
|
|
26
|
+
"@bahmutov/cy-rollup": "^2.0.0",
|
|
27
|
+
"@cypress/react": "^7.0.2",
|
|
28
|
+
"@cypress/webpack-preprocessor": "^5.16.1",
|
|
23
29
|
"@emotion/css": "11.10.5",
|
|
24
30
|
"@emotion/react": "11.10.5",
|
|
25
31
|
"@emotion/styled": "11.10.5",
|
|
@@ -30,30 +36,8 @@
|
|
|
30
36
|
"@mui/icons-material": "5.11.0",
|
|
31
37
|
"@mui/material": "5.11.6",
|
|
32
38
|
"@mui/styles": "5.11.2",
|
|
33
|
-
"@turf/turf": "^6.5.0",
|
|
34
|
-
"d3": "^7.8.2",
|
|
35
|
-
"jspdf": "^2.5.1",
|
|
36
|
-
"maplibre-gl": "^2.4.0",
|
|
37
|
-
"mui-color": "^2.0.0-beta.2",
|
|
38
|
-
"react-draggable": "^4.4.5",
|
|
39
|
-
"react-i18next": "^12.1.4",
|
|
40
|
-
"react-moveable": "^0.45.1",
|
|
41
|
-
"storybook-source-link": "^2.0.4",
|
|
42
|
-
"three": "^0.149.0",
|
|
43
|
-
"uuid": "^9.0.0",
|
|
44
|
-
"wms-capabilities": "^0.6.0",
|
|
45
|
-
"xmldom": "^0.6.0"
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@babel/preset-react": "^7.18.6",
|
|
50
|
-
"@bahmutov/cy-rollup": "^2.0.0",
|
|
51
|
-
"@cypress/react": "^7.0.2",
|
|
52
|
-
"@cypress/webpack-preprocessor": "^5.16.1",
|
|
53
|
-
"@rollup/plugin-alias": "^4.0.3",
|
|
54
39
|
"@rollup/plugin-babel": "^6.0.3",
|
|
55
40
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
56
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
57
41
|
"@rollup/plugin-url": "^8.0.1",
|
|
58
42
|
"@storybook/addon-actions": "^6.5.16",
|
|
59
43
|
"@storybook/addon-docs": "^6.5.16",
|
|
@@ -69,6 +53,7 @@
|
|
|
69
53
|
"@storybook/theming": "^6.5.16",
|
|
70
54
|
"@svgr/rollup": "^6.5.1",
|
|
71
55
|
"@testing-library/react": "^13.4.0",
|
|
56
|
+
"@turf/turf": "^6.5.0",
|
|
72
57
|
"@types/enzyme": "^3.10.12",
|
|
73
58
|
"@types/expect": "^24.3.0",
|
|
74
59
|
"@types/jest": "^29.4.0",
|
|
@@ -88,6 +73,7 @@
|
|
|
88
73
|
"babel-plugin-styled-components": "^2.0.7",
|
|
89
74
|
"babel-preset-react-app": "^10.0.1",
|
|
90
75
|
"cypress": "^12.4.1",
|
|
76
|
+
"d3": "^7.8.2",
|
|
91
77
|
"enzyme": "^3.11.0",
|
|
92
78
|
"eslint": "^8.32.0",
|
|
93
79
|
"eslint-config-prettier": "^8.6.0",
|
|
@@ -99,6 +85,9 @@
|
|
|
99
85
|
"jest-enzyme": "^7.1.2",
|
|
100
86
|
"jest-resolve": "26.6.0",
|
|
101
87
|
"jest-watch-typeahead": "0.6.1",
|
|
88
|
+
"jspdf": "^2.5.1",
|
|
89
|
+
"maplibre-gl": "^2.4.0",
|
|
90
|
+
"mui-color": "^2.0.0-beta.2",
|
|
102
91
|
"node-fetch": "^3.3.0",
|
|
103
92
|
"postcss": "^8.4.21",
|
|
104
93
|
"prettier": "2.8.3",
|
|
@@ -106,18 +95,22 @@
|
|
|
106
95
|
"react-app-polyfill": "^3.0.0",
|
|
107
96
|
"react-dev-utils": "^12.0.1",
|
|
108
97
|
"react-dom": "^18.2.0",
|
|
98
|
+
"react-draggable": "^4.4.5",
|
|
99
|
+
"react-i18next": "^12.1.4",
|
|
100
|
+
"react-moveable": "^0.45.1",
|
|
109
101
|
"rollup": "^2.70.1",
|
|
110
102
|
"rollup-plugin-delete": "^2.0.0",
|
|
111
103
|
"rollup-plugin-import-css": "^3.0.3",
|
|
112
|
-
"rollup-plugin-
|
|
113
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
104
|
+
"rollup-plugin-node-externals": "^5.1.2",
|
|
114
105
|
"rollup-plugin-typescript2": "^0.31.2",
|
|
115
106
|
"showdown": "^2.1.0",
|
|
107
|
+
"storybook-source-link": "^2.0.4",
|
|
108
|
+
"three": "^0.149.0",
|
|
116
109
|
"ts-jest": "^29.0.5",
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
110
|
+
"typescript": "^4.9.4",
|
|
111
|
+
"uuid": "^9.0.0",
|
|
112
|
+
"wms-capabilities": "^0.6.0",
|
|
113
|
+
"xmldom": "^0.6.0"
|
|
121
114
|
},
|
|
122
115
|
"jest": {
|
|
123
116
|
"roots": [
|
|
@@ -152,7 +145,7 @@
|
|
|
152
145
|
"moduleNameMapper": {
|
|
153
146
|
"^react-native$": "react-native-web",
|
|
154
147
|
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
|
|
155
|
-
"
|
|
148
|
+
"^maplibre-gl/dist/maplibre-gl$": "<rootDir>/node_modules/maplibre-gl",
|
|
156
149
|
"d3": "<rootDir>/node_modules/d3/dist/d3.min.js"
|
|
157
150
|
},
|
|
158
151
|
"moduleFileExtensions": [
|
package/rollup.config.js
CHANGED
|
@@ -1,57 +1,74 @@
|
|
|
1
|
-
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
1
|
import commonjs from '@rollup/plugin-commonjs';
|
|
4
2
|
import typescript from 'rollup-plugin-typescript2';
|
|
3
|
+
import { defineConfig } from 'rollup';
|
|
5
4
|
|
|
6
5
|
import babel from '@rollup/plugin-babel';
|
|
7
6
|
import url from '@rollup/plugin-url';
|
|
8
|
-
import
|
|
7
|
+
import externals from 'rollup-plugin-node-externals';
|
|
9
8
|
|
|
10
9
|
import css from 'rollup-plugin-import-css';
|
|
11
10
|
import del from 'rollup-plugin-delete';
|
|
12
11
|
import svgr from '@svgr/rollup';
|
|
13
12
|
|
|
14
|
-
import pkg from
|
|
13
|
+
import pkg from './package.json';
|
|
15
14
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
svgr({
|
|
21
|
-
svgo: false,
|
|
22
|
-
}),
|
|
23
|
-
url(),
|
|
24
|
-
babel({
|
|
25
|
-
exclude: 'node_modules/**',
|
|
26
|
-
babelHelpers: 'bundled',
|
|
27
|
-
presets: ['@babel/preset-react'],
|
|
28
|
-
}),
|
|
29
|
-
external(),
|
|
30
|
-
peerDepsExternal(),
|
|
31
|
-
resolve(),
|
|
32
|
-
commonjs(),
|
|
33
|
-
typescript({
|
|
34
|
-
useTsconfigDeclarationDir: true,
|
|
35
|
-
tsconfig: 'tsconfig.json',
|
|
36
|
-
}),
|
|
37
|
-
css(),
|
|
38
|
-
del({ targets: ['build/*'] }),
|
|
39
|
-
],
|
|
40
|
-
external: [
|
|
41
|
-
'!maplibre-gl',
|
|
42
|
-
'prop-types',
|
|
43
|
-
'd3',
|
|
44
|
-
'@emotion/react',
|
|
45
|
-
'@emotion/styled',
|
|
46
|
-
'@babel/helpers',
|
|
47
|
-
'jspdf',
|
|
48
|
-
...Object.keys(pkg.dependencies),
|
|
49
|
-
...Object.keys(pkg.peerDependencies),
|
|
50
|
-
...Object.keys(pkg.devDependencies),
|
|
51
|
-
],
|
|
52
|
-
inlineDynamicImports: true,
|
|
53
|
-
onwarn: function (warning, warn) {
|
|
54
|
-
warn(warning);
|
|
55
|
-
},
|
|
15
|
+
const externalsConfig = {
|
|
16
|
+
deps: true,
|
|
17
|
+
devDeps: true,
|
|
18
|
+
exclude:['react', 'react-dom']
|
|
56
19
|
};
|
|
20
|
+
|
|
21
|
+
const config = defineConfig([
|
|
22
|
+
// CJS config
|
|
23
|
+
//{
|
|
24
|
+
// input: ['src/index.ts'],
|
|
25
|
+
// output: {
|
|
26
|
+
// file: 'dist/index.js',
|
|
27
|
+
// format: 'cjs',
|
|
28
|
+
// sourcemap: true,
|
|
29
|
+
// },
|
|
30
|
+
// plugins: [
|
|
31
|
+
// svgr({
|
|
32
|
+
// svgo: false,
|
|
33
|
+
// }),
|
|
34
|
+
// url(),
|
|
35
|
+
// babel(),
|
|
36
|
+
// externals(externalsConfig),
|
|
37
|
+
// typescript({ declarationDir: 'dist/types', sourceMap: true }),
|
|
38
|
+
// css(),
|
|
39
|
+
// del({ targets: ['dist/*'] }),
|
|
40
|
+
// ],
|
|
41
|
+
//},
|
|
42
|
+
// ESM config
|
|
43
|
+
{
|
|
44
|
+
input: ['src/index.ts'],
|
|
45
|
+
output: {
|
|
46
|
+
file: 'dist/index.esm.js',
|
|
47
|
+
format: 'cjs',
|
|
48
|
+
sourcemap: true,
|
|
49
|
+
},
|
|
50
|
+
plugins: [
|
|
51
|
+
svgr({
|
|
52
|
+
svgo: false,
|
|
53
|
+
}),
|
|
54
|
+
url(),
|
|
55
|
+
babel({
|
|
56
|
+
presets: ['@babel/preset-react'],
|
|
57
|
+
}),
|
|
58
|
+
externals(externalsConfig),
|
|
59
|
+
commonjs(),
|
|
60
|
+
typescript({ declarationDir: 'dist/types', sourceMap: true }),
|
|
61
|
+
css(),
|
|
62
|
+
del({ targets: ['dist/*'] }),
|
|
63
|
+
],
|
|
64
|
+
external: [
|
|
65
|
+
'react',
|
|
66
|
+
'react-dom',
|
|
67
|
+
'd3',
|
|
68
|
+
...Object.keys(pkg.dependencies),
|
|
69
|
+
...Object.keys(pkg.peerDependencies),
|
|
70
|
+
...Object.keys(pkg.devDependencies),
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
57
74
|
export default config;
|
package/src/App.css
CHANGED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* #root {
|
|
3
|
-
background-color: #000;
|
|
4
|
-
position: absolute;
|
|
5
|
-
min-height: 400px;
|
|
6
|
-
top: 0;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
right: 0;
|
|
10
|
-
}
|
|
11
|
-
.docs-story {
|
|
12
|
-
min-height: 400px;
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: stretch;
|
|
15
|
-
}
|
|
16
|
-
.docs-story > div:first-child {
|
|
17
|
-
width: 100%;
|
|
18
|
-
}
|
|
19
|
-
.MuiToolbar-root .MuiButtonBase-root {
|
|
20
|
-
margin-right: 8px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.App {
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 0;
|
|
26
|
-
right: 0;
|
|
27
|
-
bottom: 0;
|
|
28
|
-
left: 0;
|
|
29
|
-
}
|
|
30
|
-
.mapContainer {
|
|
31
|
-
position: absolute;
|
|
32
|
-
height: 100vh;
|
|
33
|
-
width: 100vw;
|
|
34
|
-
top: 0;
|
|
35
|
-
right: 0;
|
|
36
|
-
left: 0;
|
|
37
|
-
bottom: 0;
|
|
38
|
-
z-index: 100;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.overlay {
|
|
42
|
-
width: 100%;
|
|
43
|
-
display: inline-flex;
|
|
44
|
-
position: fixed;
|
|
45
|
-
top: 0;
|
|
46
|
-
left: 0;
|
|
47
|
-
background-color: transparent;
|
|
48
|
-
z-index: 1 !important;
|
|
49
|
-
padding-top: 1rem;
|
|
50
|
-
padding-left: 1rem;
|
|
51
|
-
}
|
|
52
|
-
.MuiToolbar-root .MuiButtonBase-root {
|
|
53
|
-
margin-right: 8px;
|
|
54
|
-
}
|
|
55
|
-
*/
|
|
@@ -1,53 +1,52 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
|
|
3
|
-
import MapLibreMap from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
3
|
+
import MapLibreMap from './MapLibreMap';
|
|
4
|
+
import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer';
|
|
5
|
+
import { Button } from '@mui/material';
|
|
6
|
+
import TopToolbar from '../../ui_components/TopToolbar';
|
|
7
|
+
import sample_geojson_1 from '../MlGeoJsonLayer/assets/sample_1.json';
|
|
8
|
+
|
|
9
|
+
import themeDecorator from '../../decorators/ThemeDecorator';
|
|
9
10
|
|
|
10
11
|
const storyoptions = {
|
|
11
|
-
title:
|
|
12
|
+
title: 'Core/MapLibreMap',
|
|
12
13
|
component: MapLibreMap,
|
|
13
14
|
argTypes: {
|
|
14
15
|
options: {
|
|
15
16
|
control: {
|
|
16
|
-
type:
|
|
17
|
+
type: 'object',
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
decorators: themeDecorator,
|
|
22
|
+
parameters: {
|
|
23
|
+
sourceLink: 'components/MapLibreMap/MapLibreMap.tsx',
|
|
24
|
+
},
|
|
24
25
|
};
|
|
25
26
|
export default storyoptions;
|
|
26
27
|
|
|
27
28
|
const Template = (args) => {
|
|
28
29
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/>
|
|
43
|
-
</MapComponentsProvider>
|
|
30
|
+
<MapLibreMap
|
|
31
|
+
options={{ ...args.options }}
|
|
32
|
+
style={{
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
height: '100vh',
|
|
35
|
+
width: '100vw',
|
|
36
|
+
top: 0,
|
|
37
|
+
right: 0,
|
|
38
|
+
left: 0,
|
|
39
|
+
bottom: 0,
|
|
40
|
+
zIndex: 100,
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
44
43
|
);
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
export const ExampleConfig = Template.bind({});
|
|
48
47
|
ExampleConfig.args = {
|
|
49
48
|
options: {
|
|
50
|
-
style:
|
|
49
|
+
style: 'https://wms.wheregroup.com/tileserver/style/osm-bright.json',
|
|
51
50
|
center: [8.607, 53.1409349],
|
|
52
51
|
zoom: 14,
|
|
53
52
|
},
|
|
@@ -55,24 +54,24 @@ ExampleConfig.args = {
|
|
|
55
54
|
|
|
56
55
|
const StyleChangeTemplate = (args) => {
|
|
57
56
|
const [activeStyle, setActiveStyle] = useState(
|
|
58
|
-
|
|
57
|
+
'https://wms.wheregroup.com/tileserver/style/osm-fiord-color.json'
|
|
59
58
|
);
|
|
60
59
|
|
|
61
60
|
return (
|
|
62
|
-
|
|
61
|
+
<>
|
|
63
62
|
<TopToolbar>
|
|
64
63
|
<Button
|
|
65
64
|
onClick={() =>
|
|
66
|
-
setActiveStyle(
|
|
65
|
+
setActiveStyle('https://wms.wheregroup.com/tileserver/style/osm-bright.json')
|
|
67
66
|
}
|
|
68
67
|
variant="contained"
|
|
69
|
-
sx={{marginRight:'5px'}}
|
|
68
|
+
sx={{ marginRight: '5px' }}
|
|
70
69
|
>
|
|
71
70
|
OSM-Bright
|
|
72
71
|
</Button>
|
|
73
72
|
<Button
|
|
74
73
|
onClick={() =>
|
|
75
|
-
setActiveStyle(
|
|
74
|
+
setActiveStyle('https://wms.wheregroup.com/tileserver/style/osm-fiord-color.json')
|
|
76
75
|
}
|
|
77
76
|
variant="contained"
|
|
78
77
|
>
|
|
@@ -82,9 +81,9 @@ const StyleChangeTemplate = (args) => {
|
|
|
82
81
|
<MapLibreMap
|
|
83
82
|
options={{ ...args.options, style: activeStyle }}
|
|
84
83
|
style={{
|
|
85
|
-
position:
|
|
86
|
-
height:
|
|
87
|
-
width:
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
height: '100vh',
|
|
86
|
+
width: '100vw',
|
|
88
87
|
top: 0,
|
|
89
88
|
right: 0,
|
|
90
89
|
left: 0,
|
|
@@ -93,7 +92,7 @@ const StyleChangeTemplate = (args) => {
|
|
|
93
92
|
}}
|
|
94
93
|
/>
|
|
95
94
|
<MlGeoJsonLayer type="line" geojson={sample_geojson_1} />
|
|
96
|
-
|
|
95
|
+
</>
|
|
97
96
|
);
|
|
98
97
|
};
|
|
99
98
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useContext, FC,
|
|
1
|
+
import React, { useRef, useEffect, useContext, FC, RefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import MapContext, { MapContextType } from
|
|
4
|
-
import MapLibreGlWrapper from
|
|
3
|
+
import MapContext, { MapContextType } from '../../contexts/MapContext';
|
|
4
|
+
import MapLibreGlWrapper from './lib/MapLibreGlWrapper';
|
|
5
5
|
|
|
6
|
-
import { MapOptions as MapOptionsType } from
|
|
7
|
-
import
|
|
6
|
+
import { MapOptions as MapOptionsType, Map } from 'maplibre-gl';
|
|
7
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
8
8
|
|
|
9
9
|
type MapLibreMapProps = {
|
|
10
10
|
/**
|
|
@@ -31,16 +31,18 @@ const defaultProps: MapLibreMapProps = {
|
|
|
31
31
|
container: '',
|
|
32
32
|
style: {
|
|
33
33
|
version: 8,
|
|
34
|
-
name:
|
|
34
|
+
name: 'blank',
|
|
35
35
|
center: [0, 0],
|
|
36
36
|
zoom: 0,
|
|
37
37
|
sources: {},
|
|
38
|
+
sprite: 'https://wms.wheregroup.com/tileserver/sprites/osm-bright',
|
|
39
|
+
glyphs: 'https://wms.wheregroup.com/tileserver/fonts/{fontstack}/{range}.pbf',
|
|
38
40
|
layers: [
|
|
39
41
|
{
|
|
40
|
-
id:
|
|
41
|
-
type:
|
|
42
|
+
id: '_background',
|
|
43
|
+
type: 'background',
|
|
42
44
|
paint: {
|
|
43
|
-
|
|
45
|
+
'background-color': 'rgba(0,0,0,0)',
|
|
44
46
|
},
|
|
45
47
|
},
|
|
46
48
|
],
|
|
@@ -81,19 +83,17 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
|
|
|
81
83
|
useEffect(() => {
|
|
82
84
|
if (initializedRef.current) return;
|
|
83
85
|
|
|
84
|
-
console.log(mapContainer.current);
|
|
85
|
-
|
|
86
86
|
if (mapContainer.current) {
|
|
87
87
|
initializedRef.current = true;
|
|
88
88
|
map.current = new MapLibreGlWrapper({
|
|
89
89
|
mapOptions: {
|
|
90
90
|
style: '',
|
|
91
91
|
...props.options,
|
|
92
|
-
...(props?.options?.style?{}:{style:defaultProps?.options?.style}),
|
|
92
|
+
...(props?.options?.style ? {} : { style: defaultProps?.options?.style }),
|
|
93
93
|
container: mapContainer.current,
|
|
94
94
|
},
|
|
95
|
-
onReady: (map:
|
|
96
|
-
map.once(
|
|
95
|
+
onReady: (map: Map, wrapper: MapLibreGlWrapper) => {
|
|
96
|
+
map.once('load', () => {
|
|
97
97
|
if (props.mapId) {
|
|
98
98
|
mapContext.registerMap(props.mapId, wrapper);
|
|
99
99
|
} else {
|
|
@@ -107,13 +107,19 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
|
|
|
107
107
|
|
|
108
108
|
useEffect(() => {
|
|
109
109
|
if (map.current?.map && props?.options?.style && currentStyle.current !== props.options.style) {
|
|
110
|
-
console.log(
|
|
110
|
+
console.log('set style');
|
|
111
111
|
currentStyle.current = props.options.style;
|
|
112
112
|
map.current.map.setStyle(props.options.style);
|
|
113
113
|
}
|
|
114
|
-
}, [props?.options?.style])
|
|
114
|
+
}, [props?.options?.style]);
|
|
115
115
|
|
|
116
|
-
return
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
ref={mapContainer as RefObject<HTMLDivElement>}
|
|
119
|
+
className="mapContainer"
|
|
120
|
+
style={props.style}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
117
123
|
};
|
|
118
124
|
|
|
119
125
|
MapLibreMap.defaultProps = defaultProps;
|