@mapcomponents/react-maplibre 0.1.48 → 0.1.52
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/.github/workflows/node_version_test.yml +2 -1
- package/CHANGELOG.md +22 -1
- package/README.md +61 -150
- package/coverage/clover.xml +269 -246
- package/coverage/coverage-final.json +10 -9
- package/coverage/lcov-report/index.html +49 -34
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +25 -25
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +343 -0
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +116 -0
- 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/MlFeatureEditor/MlFeatureEditor.tsx.html +69 -63
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +18 -18
- 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/MlGPXViewer/MlGPXViewer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +26 -11
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/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 +106 -34
- 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.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/MlSpatialElevationProfile/MlSpatialElevationProfile.js.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 +22 -19
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +23 -23
- 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 +15 -15
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +78 -69
- package/coverage/lcov-report/src/hooks/useMap.ts.html +25 -25
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +28 -28
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov.info +544 -494
- package/dist/components/MapLibreMap/MapLibreMap.d.ts +31 -0
- package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +15 -0
- package/dist/components/MapLibreMap/MapLibreMap.test.d.ts +1 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +76 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.test.d.ts +1 -0
- package/dist/components/MlBasicComponent.d.ts +5 -0
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +50 -0
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +17 -0
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +22 -0
- package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +10 -0
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +21 -0
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +10 -0
- package/dist/components/MlCreatePdfButton/lib/createPdf.d.ts +2 -0
- package/dist/components/MlCreatePdfButton/lib/nominatimMap.d.ts +2 -0
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +35 -0
- package/dist/components/MlFeatureEditor/MlFeatureEditor.stories.d.ts +15 -0
- package/dist/components/MlFeatureEditor/MlFeatureEditor.test.d.ts +1 -0
- package/dist/components/MlFeatureEditor/custom-direct-select-mode.d.ts +37 -0
- package/dist/components/MlFeatureEditor/custom-polygon-mode.d.ts +16 -0
- package/dist/components/MlFeatureEditor/custom-select-mode.d.ts +37 -0
- package/dist/components/MlFeatureEditor/lib/common_selectors.d.ts +11 -0
- package/dist/components/MlFeatureEditor/lib/constants.d.ts +85 -0
- package/dist/components/MlFeatureEditor/lib/constrain_feature_movement.d.ts +2 -0
- package/dist/components/MlFeatureEditor/lib/create_midpoint.d.ts +15 -0
- package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +2 -0
- package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +13 -0
- package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +7 -0
- package/dist/components/MlFeatureEditor/lib/euclidean_distance.d.ts +5 -0
- package/dist/components/MlFeatureEditor/lib/features_at.d.ts +7 -0
- package/dist/components/MlFeatureEditor/lib/get_features_and_set_cursor.d.ts +1 -0
- package/dist/components/MlFeatureEditor/lib/is_click.d.ts +1 -0
- package/dist/components/MlFeatureEditor/lib/is_event_at_coordinates.d.ts +6 -0
- package/dist/components/MlFeatureEditor/lib/is_tap.d.ts +3 -0
- package/dist/components/MlFeatureEditor/lib/map_event_to_bounding_box.d.ts +12 -0
- package/dist/components/MlFeatureEditor/lib/mode_handler.d.ts +24 -0
- package/dist/components/MlFeatureEditor/lib/mouse_event_point.d.ts +11 -0
- package/dist/components/MlFeatureEditor/lib/move_features.d.ts +2 -0
- package/dist/components/MlFeatureEditor/lib/sort_features.d.ts +2 -0
- package/dist/components/MlFeatureEditor/lib/string_set.d.ts +21 -0
- package/dist/components/MlFeatureEditor/lib/string_sets_are_equal.d.ts +5 -0
- package/dist/components/MlFeatureEditor/lib/theme.d.ts +88 -0
- package/dist/components/MlFeatureEditor/lib/to_dense_array.d.ts +12 -0
- package/dist/components/MlFeatureEditor/lib/utils.d.ts +10 -0
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +61 -0
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.d.ts +10 -0
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.test.d.ts +1 -0
- package/dist/components/MlFollowGps/MlFollowGps.d.ts +80 -0
- package/dist/components/MlFollowGps/MlFollowGps.stories.d.ts +10 -0
- package/dist/components/MlFollowGps/MlFollowGps.test.d.ts +1 -0
- package/dist/components/MlGPXViewer/MlGPXViewer.d.ts +29 -0
- package/dist/components/MlGPXViewer/MlGPXViewer.stories.d.ts +16 -0
- package/dist/components/MlGPXViewer/MlGPXViewer.test.d.ts +1 -0
- package/dist/components/MlGPXViewer/gpxConverter.d.ts +11 -0
- package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +10 -0
- package/dist/components/MlGPXViewer/util/GeoJsonProvider.d.ts +4 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +76 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +12 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.test.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.d.ts +2 -0
- package/dist/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +2 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +29 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +10 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.test.d.ts +1 -0
- package/dist/components/MlLayer/MlLayer.d.ts +26 -0
- package/dist/components/MlLayer/MlLayer.stories.d.ts +10 -0
- package/dist/components/MlLayer/MlLayer.test.d.ts +1 -0
- package/dist/components/MlLayerMagnify/MlLayerMagnify.d.ts +27 -0
- package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +10 -0
- package/dist/components/MlLayerMagnify/MlLayerMagnify.test.d.ts +1 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +16 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +11 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.test.d.ts +1 -0
- package/dist/components/MlLayerSwitcher/MlLayerSwitcher.d.ts +30 -0
- package/dist/components/MlLayerSwitcher/MlLayerSwitcher.stories.d.ts +13 -0
- package/dist/components/MlLayerSwitcher/components/LayerBox.d.ts +6 -0
- package/dist/components/MlMarker/MlMarker.d.ts +33 -0
- package/dist/components/MlMarker/MlMarker.stories.d.ts +9 -0
- package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +20 -0
- package/dist/components/MlMeasureTool/MlMeasureTool.stories.d.ts +11 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.d.ts +47 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.stories.d.ts +10 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.test.d.ts +1 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +31 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +13 -0
- package/dist/components/MlOsmLayer/MlOsmLayer.d.ts +18 -0
- package/dist/components/MlOsmLayer/MlOsmLayer.stories_.d.ts +16 -0
- package/dist/components/MlOsmLayer/MlOsmLayer.test.d.ts +1 -0
- package/dist/components/MlScaleReference/MlScaleReference.d.ts +2 -0
- package/dist/components/MlScaleReference/MlScaleReference.stories.d.ts +14 -0
- package/dist/components/MlShareMapState/MlShareMapState.d.ts +22 -0
- package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +10 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +20 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +16 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.d.ts +1 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.d.ts +15 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +16 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.test.d.ts +1 -0
- package/dist/components/MlThreeJsLayer/lib/GLTFLoader.d.ts +17 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +73 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.d.ts +13 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.test.d.ts +1 -0
- package/dist/components/MlTransitionGeoJsonLayer/util/transitionFunctions.d.ts +2 -0
- package/dist/components/MlUseMapDebugger/MlUseMapDebugger.d.ts +22 -0
- package/dist/components/MlUseMapDebugger/MlUseMapDebugger.stories.d.ts +13 -0
- package/dist/components/MlVectorTileLayer/MlVectorTileLayer.d.ts +37 -0
- package/dist/components/MlVectorTileLayer/MlVectorTileLayer.stories.d.ts +13 -0
- package/dist/components/MlVectorTileLayer/MlVectorTileLayer.test.d.ts +1 -0
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.d.ts +22 -0
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +13 -0
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +100 -0
- package/dist/components/MlWmsLayer/MlWmsLayer.stories.d.ts +13 -0
- package/dist/components/MlWmsLayer/MlWmsLayer.test.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +48 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +13 -0
- package/dist/contexts/MapComponentsProvider.test.d.ts +1 -0
- package/dist/contexts/MapContext.d.ts +13 -0
- package/dist/contexts/SimpleDataContext.d.ts +4 -0
- package/dist/contexts/SimpleDataProvider.d.ts +8 -0
- package/dist/contexts/SimpleDataProvider.test.d.ts +1 -0
- package/dist/custom.d.d.ts +22 -0
- package/dist/decorators/MapContextDecorator.d.ts +2 -0
- package/dist/decorators/MultiMapContextDecorator.d.ts +2 -0
- package/dist/hooks/useLayer.d.ts +26 -0
- package/dist/hooks/useLayer.test.d.ts +1 -0
- package/dist/hooks/useMap.d.ts +14 -0
- package/dist/hooks/useMapState.d.ts +62 -0
- package/dist/hooks/useMapState.stories.d.ts +14 -0
- package/dist/hooks/useWms.d.ts +18 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.esm.js +96 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/setupTests.d.ts +12 -0
- package/dist/stories/components/Readme.d.ts +2 -0
- package/dist/ui_components/ImageLoader.d.ts +2 -0
- package/dist/ui_components/Legend.d.ts +1 -0
- package/dist/ui_components/LoadingOverlay.d.ts +2 -0
- package/dist/ui_components/LoadingOverlayContext.d.ts +11 -0
- package/dist/ui_components/Sidebar.d.ts +1 -0
- package/dist/ui_components/Tooltip.d.ts +1 -0
- package/dist/ui_components/TopToolbar.d.ts +1 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/layerRemovalTest.d.ts +2 -0
- package/dist/util/sourceRemovalTest.d.ts +2 -0
- package/package.json +2 -1
- package/scripts/create-map-component.sh +2 -2
- package/src/components/MapLibreMap/MapLibreMap.tsx +1 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +4 -3
- package/src/components/MlCenterPosition/MlCenterPosition.doc.de.md +3 -0
- package/src/components/MlCenterPosition/MlCenterPosition.meta_.json +15 -0
- package/src/components/MlCenterPosition/MlCenterPosition.stories.js +21 -0
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +86 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +1 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +3 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +37 -35
- package/src/components/MlFeatureEditor/lib/utils.js +1 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +14 -9
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +2 -1
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +3 -2
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +44 -20
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +18 -17
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +1 -1
- package/src/hooks/useLayer.test.js +205 -0
- package/src/hooks/useLayer.ts +11 -8
- package/tsconfig.json +35 -7
- package/docs-build/0.20735a16c2ad9677fe7d.manager.bundle.js +0 -1
- package/docs-build/0.968bdc5f.iframe.bundle.js +0 -2
- package/docs-build/0.968bdc5f.iframe.bundle.js.map +0 -1
- package/docs-build/1.3530bc86.iframe.bundle.js +0 -10
- package/docs-build/1.3530bc86.iframe.bundle.js.map +0 -1
- package/docs-build/17.c96fb6bc.iframe.bundle.js +0 -2
- package/docs-build/17.c96fb6bc.iframe.bundle.js.map +0 -1
- package/docs-build/18.0947f810.iframe.bundle.js +0 -17
- package/docs-build/18.0947f810.iframe.bundle.js.map +0 -1
- package/docs-build/19.44204e5a.iframe.bundle.js +0 -14
- package/docs-build/19.44204e5a.iframe.bundle.js.map +0 -1
- package/docs-build/2.c62e9630.iframe.bundle.js +0 -2
- package/docs-build/2.c62e9630.iframe.bundle.js.map +0 -1
- package/docs-build/20.50a2ad76.iframe.bundle.js +0 -2
- package/docs-build/20.50a2ad76.iframe.bundle.js.map +0 -1
- package/docs-build/21.ce55b70e.iframe.bundle.js +0 -4
- package/docs-build/21.ce55b70e.iframe.bundle.js.map +0 -1
- package/docs-build/22.639c6bb4.iframe.bundle.js +0 -22
- package/docs-build/22.639c6bb4.iframe.bundle.js.map +0 -1
- package/docs-build/3.afb0e0a5.iframe.bundle.js +0 -2
- package/docs-build/3.afb0e0a5.iframe.bundle.js.map +0 -1
- package/docs-build/4.8ac31bba1926f4f011b0.manager.bundle.js +0 -2
- package/docs-build/4.8ac31bba1926f4f011b0.manager.bundle.js.LICENSE.txt +0 -8
- package/docs-build/5.daf044a6c0f55d839078.manager.bundle.js +0 -1
- package/docs-build/6.99fba2cf6af0473f8209.manager.bundle.js +0 -2
- package/docs-build/6.99fba2cf6af0473f8209.manager.bundle.js.LICENSE.txt +0 -12
- package/docs-build/7.b6a48b90f61cb575c2e4.manager.bundle.js +0 -1
- package/docs-build/8.50518a5391398d9d5812.manager.bundle.js +0 -1
- package/docs-build/assets/3D/godzilla_simple.glb +0 -0
- package/docs-build/assets/dop.png +0 -0
- package/docs-build/assets/historic.png +0 -0
- package/docs-build/assets/marker.png +0 -0
- package/docs-build/assets/osm.png +0 -0
- package/docs-build/assets/sample.gpx +0 -716
- package/docs-build/catalogue/.gitkeep +0 -0
- package/docs-build/catalogue/mc_meta.json +0 -1
- package/docs-build/favicon.ico +0 -0
- package/docs-build/iframe.html +0 -348
- package/docs-build/index.html +0 -59
- package/docs-build/logo.png +0 -0
- package/docs-build/main.ef9704b1252e8efa56a0.manager.bundle.js +0 -1
- package/docs-build/main~24120820.e956ad2c.iframe.bundle.js +0 -2
- package/docs-build/main~24120820.e956ad2c.iframe.bundle.js.map +0 -1
- package/docs-build/manifest.json +0 -25
- package/docs-build/robots.txt +0 -3
- package/docs-build/runtime~main.6e6ed7dc9ea4785ef286.manager.bundle.js +0 -1
- package/docs-build/static/media/mapcomponents_logo.98b01a05.png +0 -0
- package/docs-build/static/media/wg-marker.bf3eeb2d.png +0 -0
- package/docs-build/thumbnails/MapLibreMap.png +0 -0
- package/docs-build/thumbnails/MlCameraFollowPath.png +0 -0
- package/docs-build/thumbnails/MlCreatePdfButton.png +0 -0
- package/docs-build/thumbnails/MlDeckGlLayer.png +0 -0
- package/docs-build/thumbnails/MlDeckGlTerrainLayer.png +0 -0
- package/docs-build/thumbnails/MlDemoDashboard.png +0 -0
- package/docs-build/thumbnails/MlFeatureEditor.png +0 -0
- package/docs-build/thumbnails/MlFillExtrusionLayer.png +0 -0
- package/docs-build/thumbnails/MlFollowGps.png +0 -0
- package/docs-build/thumbnails/MlGPXViewer.png +0 -0
- package/docs-build/thumbnails/MlGeoJsonLayer.png +0 -0
- package/docs-build/thumbnails/MlHillshadeLayer.png +0 -0
- package/docs-build/thumbnails/MlIconLayer.png +0 -0
- package/docs-build/thumbnails/MlLaermkarte.png +0 -0
- package/docs-build/thumbnails/MlLayerMagnify.png +0 -0
- package/docs-build/thumbnails/MlLayerSwipe.png +0 -0
- package/docs-build/thumbnails/MlMapDrawTools.png +0 -0
- package/docs-build/thumbnails/MlMeasureTool.png +0 -0
- package/docs-build/thumbnails/MlMobilerImker.png +0 -0
- package/docs-build/thumbnails/MlNavigationCompass.png +0 -0
- package/docs-build/thumbnails/MlNavigationTools.png +0 -0
- package/docs-build/thumbnails/MlOsmLayer.png +0 -0
- package/docs-build/thumbnails/MlScaleReference.png +0 -0
- package/docs-build/thumbnails/MlSpatialElevationProfile.png +0 -0
- package/docs-build/thumbnails/MlThreeJsLayer.png +0 -0
- package/docs-build/thumbnails/MlTransitionGeoJsonLayer.png +0 -0
- package/docs-build/thumbnails/MlVectorTileLayer.png +0 -0
- package/docs-build/thumbnails/MlWanderApp.png +0 -0
- package/docs-build/thumbnails/MlWmsLayer.png +0 -0
- package/docs-build/thumbnails/MlWmsLoader.png +0 -0
- package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js +0 -2
- package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js.LICENSE.txt +0 -104
- package/docs-build/vendors~main~0ad7406a.834c9ace.iframe.bundle.js +0 -8
- package/docs-build/vendors~main~0ad7406a.834c9ace.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~0f485567.7297d057.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~0f485567.7297d057.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~41a6ab2c.19d97527.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~41a6ab2c.19d97527.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~52589227.cebbe724.iframe.bundle.js +0 -8
- package/docs-build/vendors~main~52589227.cebbe724.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~57c1f6cb.8a8dd47e.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~57c1f6cb.8a8dd47e.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~73914085.2e61c0dc.iframe.bundle.js +0 -293
- package/docs-build/vendors~main~73914085.2e61c0dc.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~9c5b28f6.32356887.iframe.bundle.js +0 -7
- package/docs-build/vendors~main~9c5b28f6.32356887.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b5906859.94dc520a.iframe.bundle.js +0 -21
- package/docs-build/vendors~main~b5906859.94dc520a.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b8f44717.8669cfb8.iframe.bundle.js +0 -89
- package/docs-build/vendors~main~b8f44717.8669cfb8.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b9cf3951.2a2025c3.iframe.bundle.js +0 -63
- package/docs-build/vendors~main~b9cf3951.2a2025c3.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~d939e436.bb2b0303.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~d939e436.bb2b0303.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~f420d588.3481b43e.iframe.bundle.js +0 -107
- package/docs-build/vendors~main~f420d588.3481b43e.iframe.bundle.js.map +0 -1
|
@@ -8,13 +8,29 @@ import MlNavigationCompass from "../MlNavigationCompass/MlNavigationCompass";
|
|
|
8
8
|
import MlFollowGps from "../MlFollowGps/MlFollowGps";
|
|
9
9
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
10
10
|
import useMap from "../../hooks/useMap";
|
|
11
|
+
import MlCenterPosition from "../MlCenterPosition/MlCenterPosition";
|
|
11
12
|
|
|
12
13
|
interface MlNavigationToolsProps {
|
|
14
|
+
/**
|
|
15
|
+
* Id of the target MapLibre instance in mapContext
|
|
16
|
+
*/
|
|
13
17
|
mapId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
20
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
21
|
+
*/
|
|
14
22
|
insertBeforeLayer?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Show follow GPS button
|
|
25
|
+
*/
|
|
26
|
+
showFollowGpsButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Show center on current position button
|
|
29
|
+
*/
|
|
30
|
+
showCenterLocationButton?: boolean;
|
|
15
31
|
}
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
/**
|
|
18
34
|
* @component
|
|
19
35
|
*/
|
|
20
36
|
const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
@@ -45,21 +61,22 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
45
61
|
useEffect(() => {
|
|
46
62
|
if (!mapHook.map) return;
|
|
47
63
|
|
|
48
|
-
mapHook.map.on(
|
|
49
|
-
|
|
64
|
+
mapHook.map.on(
|
|
65
|
+
"pitchend",
|
|
66
|
+
() => {
|
|
67
|
+
if (!mapHook.map) return;
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
setPitch(mapHook.map.map.getPitch());
|
|
70
|
+
},
|
|
71
|
+
mapHook.componentId
|
|
72
|
+
);
|
|
53
73
|
setPitch(mapHook.map.map.getPitch());
|
|
54
74
|
}, [mapHook.map, props.mapId]);
|
|
55
75
|
|
|
56
76
|
const zoomIn = () => {
|
|
57
77
|
if (!mapHook.map) return;
|
|
58
78
|
|
|
59
|
-
if (
|
|
60
|
-
mapHook.map.map.transform._zoom + 0.5 <=
|
|
61
|
-
mapHook.map.map.transform._maxZoom
|
|
62
|
-
) {
|
|
79
|
+
if (mapHook.map.map.transform._zoom + 0.5 <= mapHook.map.map.transform._maxZoom) {
|
|
63
80
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom + 0.5 });
|
|
64
81
|
}
|
|
65
82
|
};
|
|
@@ -67,10 +84,7 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
67
84
|
const zoomOut = () => {
|
|
68
85
|
if (!mapHook.map) return;
|
|
69
86
|
|
|
70
|
-
if (
|
|
71
|
-
mapHook.map.map.transform._zoom - 0.5 >=
|
|
72
|
-
mapHook.map.map.transform._minZoom
|
|
73
|
-
) {
|
|
87
|
+
if (mapHook.map.map.transform._zoom - 0.5 >= mapHook.map.map.transform._minZoom) {
|
|
74
88
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom - 0.5 });
|
|
75
89
|
}
|
|
76
90
|
};
|
|
@@ -108,10 +122,18 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
108
122
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
|
|
109
123
|
}}
|
|
110
124
|
/>
|
|
111
|
-
<Button
|
|
125
|
+
<Button
|
|
126
|
+
sx={{ ...buttonStyle, fontSize: mediaIsMobile ? "1.4em" : "1em", fontWeight: 600 }}
|
|
127
|
+
onClick={adjustPitch}
|
|
128
|
+
>
|
|
112
129
|
{pitch ? "2D" : "3D"}
|
|
113
130
|
</Button>
|
|
131
|
+
{props.showFollowGpsButton &&
|
|
114
132
|
<MlFollowGps style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
133
|
+
}
|
|
134
|
+
{props.showCenterLocationButton &&
|
|
135
|
+
<MlCenterPosition style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
136
|
+
}
|
|
115
137
|
<ButtonGroup
|
|
116
138
|
orientation="vertical"
|
|
117
139
|
sx={{
|
|
@@ -122,18 +144,20 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
122
144
|
}}
|
|
123
145
|
>
|
|
124
146
|
<Button sx={{ ...buttonStyle, color: "#ececec" }} onClick={zoomIn}>
|
|
125
|
-
<ControlPointIcon
|
|
126
|
-
sx={{ fontSize: mediaIsMobile ? "1.5em" : "1.2em" }}
|
|
127
|
-
/>
|
|
147
|
+
<ControlPointIcon sx={{ fontSize: mediaIsMobile ? "1.5em" : "1.2em" }} />
|
|
128
148
|
</Button>
|
|
129
149
|
<Button sx={{ ...buttonStyle, color: "#ececec" }} onClick={zoomOut}>
|
|
130
|
-
<RemoveCircleOutlineIcon
|
|
131
|
-
sx={{ fontSize: mediaIsMobile ? "1.5em" : "1.2em" }}
|
|
132
|
-
/>
|
|
150
|
+
<RemoveCircleOutlineIcon sx={{ fontSize: mediaIsMobile ? "1.5em" : "1.2em" }} />
|
|
133
151
|
</Button>
|
|
134
152
|
</ButtonGroup>
|
|
135
153
|
</div>
|
|
136
154
|
);
|
|
137
155
|
};
|
|
138
156
|
|
|
157
|
+
MlNavigationTools.defaultProps = {
|
|
158
|
+
mapId: undefined,
|
|
159
|
+
showFollowGpsButton: true,
|
|
160
|
+
showCenterLocationButton: false,
|
|
161
|
+
};
|
|
162
|
+
|
|
139
163
|
export default MlNavigationTools;
|
|
@@ -7,6 +7,7 @@ import useMap from "../../hooks/useMap";
|
|
|
7
7
|
import { _transitionToGeojson } from "./util/transitionFunctions";
|
|
8
8
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
9
9
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
|
+
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification, MapLayerMouseEvent } from "maplibre-gl";
|
|
10
11
|
|
|
11
12
|
const msPerStep = 50;
|
|
12
13
|
|
|
@@ -15,57 +16,57 @@ interface MlTransitionGeoJsonLayerProps {
|
|
|
15
16
|
* Id of the target MapLibre instance in mapContext
|
|
16
17
|
*/
|
|
17
18
|
mapId: string;
|
|
19
|
+
/**
|
|
20
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
21
|
+
*/
|
|
22
|
+
geojson: Feature | FeatureCollection | undefined;
|
|
18
23
|
/**
|
|
19
24
|
* Type of the layer that will be added to the MapLibre instance.
|
|
20
25
|
* Possible values: "line", "circle", "fill"
|
|
21
26
|
*/
|
|
22
|
-
type
|
|
27
|
+
type?: "fill" | "line" | "circle";
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* Paint property object, that is passed to the addLayer call.
|
|
25
30
|
* Possible props depend on the layer type.
|
|
26
31
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
27
32
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
28
33
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
29
34
|
*/
|
|
30
|
-
|
|
35
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['paint'];
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
37
|
+
* Layout property object, that is passed to the addLayer call.
|
|
33
38
|
* Possible props depend on the layer type.
|
|
34
39
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
35
40
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
36
41
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
37
42
|
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
41
|
-
*/
|
|
42
|
-
defaultPaintOverrides: any;
|
|
43
|
+
layout?: CircleLayerSpecification['layout'] | FillLayerSpecification['layout'] | LineLayerSpecification['layout'];
|
|
43
44
|
/**
|
|
44
45
|
* Javascript object that is spread into the addLayer commands first parameter.
|
|
45
46
|
*/
|
|
46
|
-
options
|
|
47
|
+
options?: CircleLayerSpecification | FillLayerSpecification | LineLayerSpecification;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
+
defaultPaintOverrides?: { circle?: CircleLayerSpecification['paint'], fill?: FillLayerSpecification['paint'], line?: LineLayerSpecification['paint'] };
|
|
51
52
|
/**
|
|
52
53
|
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
53
54
|
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
54
55
|
*/
|
|
55
56
|
insertBeforeLayer: string;
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
+
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
58
59
|
*/
|
|
59
|
-
|
|
60
|
+
onHover?: MapLayerMouseEvent;
|
|
60
61
|
/**
|
|
61
|
-
*
|
|
62
|
+
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
onClick?: MapLayerMouseEvent;
|
|
64
65
|
/**
|
|
65
66
|
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
66
67
|
* left/unhovered.
|
|
67
68
|
*/
|
|
68
|
-
onLeave
|
|
69
|
+
onLeave?: MapLayerMouseEvent;
|
|
69
70
|
/**
|
|
70
71
|
* Creates transition animation whenever the geojson prop changes.
|
|
71
72
|
* Only works with layer type "line" and LineString GeoJSON data.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { useContext, useState } from "react";
|
|
2
|
+
import { mount, configure } from "enzyme";
|
|
3
|
+
import MapContext, { MapComponentsProvider } from "../contexts/MapContext";
|
|
4
|
+
import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
|
|
5
|
+
import { waitFor } from "@testing-library/react";
|
|
6
|
+
import { mockMapLibreMethods } from "../setupTests";
|
|
7
|
+
|
|
8
|
+
import useLayer from "./useLayer";
|
|
9
|
+
|
|
10
|
+
const UseLayerTestComponent = (props) => {
|
|
11
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
12
|
+
useLayer({
|
|
13
|
+
mapId: props.mapId,
|
|
14
|
+
layerId: props.layerId || "TestComponent",
|
|
15
|
+
geojson: props.geojson,
|
|
16
|
+
options: {
|
|
17
|
+
paint: props.paint,
|
|
18
|
+
layout: props.layout || {},
|
|
19
|
+
type: props.type,
|
|
20
|
+
...props.options,
|
|
21
|
+
},
|
|
22
|
+
insertBeforeLayer: props.insertBeforeLayer,
|
|
23
|
+
onHover: props.onHover,
|
|
24
|
+
onClick: props.onClick,
|
|
25
|
+
onLeave: props.onLeave,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return <></>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const TestComponent = (props) => {
|
|
32
|
+
const [includeComponent, setIncludeComponent] = useState(true);
|
|
33
|
+
const [testType, setTestType] = useState('line');
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<button
|
|
38
|
+
className="change_testType"
|
|
39
|
+
onClick={() => {
|
|
40
|
+
setTestType('circle');
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
change type
|
|
44
|
+
</button>
|
|
45
|
+
<button
|
|
46
|
+
className="toggle_includeComponent"
|
|
47
|
+
onClick={() => {
|
|
48
|
+
setIncludeComponent(!includeComponent);
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
toggle
|
|
52
|
+
</button>
|
|
53
|
+
{includeComponent && <UseLayerTestComponent {...props} type={testType} />}
|
|
54
|
+
<MapLibreMap />
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
describe("useLayer hook", () => {
|
|
60
|
+
it("should register 1 event listener 'hover' to the maplibre instance", async () => {
|
|
61
|
+
var testAttributes = {
|
|
62
|
+
onHover: () => {},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const wrapper = mount(
|
|
66
|
+
<MapComponentsProvider>
|
|
67
|
+
<TestComponent {...testAttributes} />
|
|
68
|
+
</MapComponentsProvider>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// MapLibreGlWrapper now subscribes to 4 events events on its own
|
|
72
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
73
|
+
await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(6));
|
|
74
|
+
});
|
|
75
|
+
it("should deregister 1 event listener 'hover' to the maplibre instance", async () => {
|
|
76
|
+
var testAttributes = {
|
|
77
|
+
onHover: () => {},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const wrapper = mount(
|
|
81
|
+
<MapComponentsProvider>
|
|
82
|
+
<TestComponent {...testAttributes} />
|
|
83
|
+
</MapComponentsProvider>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
wrapper.find(".toggle_includeComponent").simulate("click");
|
|
87
|
+
|
|
88
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
89
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
90
|
+
});
|
|
91
|
+
it("should register 1 event listener 'leave' to the maplibre instance", async () => {
|
|
92
|
+
var testAttributes = {
|
|
93
|
+
onLeave: () => {},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const wrapper = mount(
|
|
97
|
+
<MapComponentsProvider>
|
|
98
|
+
<TestComponent {...testAttributes} />
|
|
99
|
+
</MapComponentsProvider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// MapLibreGlWrapper now subscribes to 4 events events on its own
|
|
103
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
104
|
+
await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(6));
|
|
105
|
+
});
|
|
106
|
+
it("should deregister 1 event listener 'leave' to the maplibre instance", async () => {
|
|
107
|
+
var testAttributes = {
|
|
108
|
+
onLeave: () => {},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const wrapper = mount(
|
|
112
|
+
<MapComponentsProvider>
|
|
113
|
+
<TestComponent {...testAttributes} />
|
|
114
|
+
</MapComponentsProvider>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
wrapper.find(".toggle_includeComponent").simulate("click");
|
|
118
|
+
|
|
119
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
120
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
it("should register 1 event listener 'click' to the maplibre instance", async () => {
|
|
125
|
+
var testAttributes = {
|
|
126
|
+
onClick: () => {},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const wrapper = mount(
|
|
130
|
+
<MapComponentsProvider>
|
|
131
|
+
<TestComponent {...testAttributes} />
|
|
132
|
+
</MapComponentsProvider>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// MapLibreGlWrapper now subscribes to 4 events events on its own
|
|
136
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
137
|
+
await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(6));
|
|
138
|
+
});
|
|
139
|
+
it("should deregister 1 event listener 'click' to the maplibre instance", async () => {
|
|
140
|
+
var testAttributes = {
|
|
141
|
+
onClick: () => {},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const wrapper = mount(
|
|
145
|
+
<MapComponentsProvider>
|
|
146
|
+
<TestComponent {...testAttributes} />
|
|
147
|
+
</MapComponentsProvider>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
wrapper.find(".toggle_includeComponent").simulate("click");
|
|
151
|
+
|
|
152
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
153
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// if props.type is changed during runtime the hook needs to remove existing additions to the maplibre instance and reinitialize its representation in the maplibre instance
|
|
157
|
+
it("should deregister 1 event listener 'hover' to the maplibre instance if type is changed during component runtime", async () => {
|
|
158
|
+
var testAttributes = {
|
|
159
|
+
onHover: () => {},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const wrapper = mount(
|
|
163
|
+
<MapComponentsProvider>
|
|
164
|
+
<TestComponent {...testAttributes} />
|
|
165
|
+
</MapComponentsProvider>
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
wrapper.find(".change_testType").simulate("click");
|
|
169
|
+
|
|
170
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
171
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
172
|
+
});
|
|
173
|
+
it("should deregister 1 event listener 'hover' to the maplibre instance if type is changed during component runtime", async () => {
|
|
174
|
+
var testAttributes = {
|
|
175
|
+
onHover: () => {},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const wrapper = mount(
|
|
179
|
+
<MapComponentsProvider>
|
|
180
|
+
<TestComponent {...testAttributes} />
|
|
181
|
+
</MapComponentsProvider>
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
wrapper.find(".change_testType").simulate("click");
|
|
185
|
+
|
|
186
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
187
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
188
|
+
});
|
|
189
|
+
it("should deregister 1 event listener 'click' to the maplibre instance if type is changed during component runtime", async () => {
|
|
190
|
+
var testAttributes = {
|
|
191
|
+
onClick: () => {},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const wrapper = mount(
|
|
195
|
+
<MapComponentsProvider>
|
|
196
|
+
<TestComponent {...testAttributes} />
|
|
197
|
+
</MapComponentsProvider>
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
wrapper.find(".change_testType").simulate("click");
|
|
201
|
+
|
|
202
|
+
// useLayer always subscribes to 'styledata' to watch whether its representation within the maplibre instance has been removed
|
|
203
|
+
await waitFor(() => expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2));
|
|
204
|
+
});
|
|
205
|
+
});
|
package/src/hooks/useLayer.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { LayerSpecification } from "maplibre-gl";
|
|
|
6
6
|
|
|
7
7
|
import MapLibreGlWrapper from "../components/MapLibreMap/lib/MapLibreGlWrapper";
|
|
8
8
|
|
|
9
|
+
import { MapLayerMouseEvent } from "maplibre-gl";
|
|
10
|
+
import { GeoJSONObject } from "@turf/turf";
|
|
11
|
+
|
|
9
12
|
type useLayerType = {
|
|
10
13
|
map: MapLibreGlWrapper | undefined;
|
|
11
14
|
layer: LayerSpecification;
|
|
@@ -20,11 +23,11 @@ interface useLayerProps {
|
|
|
20
23
|
idPrefix?: string;
|
|
21
24
|
insertBeforeLayer?: string;
|
|
22
25
|
insertBeforeFirstSymbolLayer?: boolean;
|
|
23
|
-
geojson?:
|
|
24
|
-
options: LayerSpecification
|
|
25
|
-
onHover?:
|
|
26
|
-
onClick?:
|
|
27
|
-
onLeave?:
|
|
26
|
+
geojson?: GeoJSONObject;
|
|
27
|
+
options: Partial<LayerSpecification>;
|
|
28
|
+
onHover?: MapLayerMouseEvent;
|
|
29
|
+
onClick?: MapLayerMouseEvent;
|
|
30
|
+
onLeave?: MapLayerMouseEvent;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const legalLayerTypes = [
|
|
@@ -116,7 +119,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
116
119
|
|
|
117
120
|
layerPaintConfRef.current = JSON.stringify(props.options?.paint);
|
|
118
121
|
layerLayoutConfRef.current = JSON.stringify(props.options?.layout);
|
|
119
|
-
layerTypeRef.current = props.options.type;
|
|
122
|
+
layerTypeRef.current = props.options.type as LayerSpecification['type'];
|
|
120
123
|
}, [props, mapHook.map]);
|
|
121
124
|
|
|
122
125
|
useEffect(() => {
|
|
@@ -124,8 +127,8 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
124
127
|
|
|
125
128
|
if (
|
|
126
129
|
initializedRef.current &&
|
|
127
|
-
(legalLayerTypes.indexOf(props.options.type) === -1 ||
|
|
128
|
-
(legalLayerTypes.indexOf(props.options.type) !== -1 &&
|
|
130
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) === -1 ||
|
|
131
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) !== -1 &&
|
|
129
132
|
props.options.type === layerTypeRef.current))
|
|
130
133
|
) {
|
|
131
134
|
return;
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"checkJs": false,
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"importHelpers": false,
|
|
6
|
+
"isolatedModules": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"strict": false,
|
|
11
|
+
"types": [
|
|
12
|
+
"node",
|
|
13
|
+
"jest",
|
|
14
|
+
"geojson"
|
|
15
|
+
],
|
|
3
16
|
"outDir": "build/esm",
|
|
4
17
|
"module": "esnext",
|
|
5
18
|
"target": "es5",
|
|
6
|
-
"lib": [
|
|
19
|
+
"lib": [
|
|
20
|
+
"es6",
|
|
21
|
+
"dom",
|
|
22
|
+
"es2016",
|
|
23
|
+
"es2017"
|
|
24
|
+
],
|
|
7
25
|
"jsx": "react",
|
|
8
26
|
"declaration": true,
|
|
27
|
+
"declarationDir": "./dist",
|
|
9
28
|
"moduleResolution": "node",
|
|
10
29
|
"noUnusedLocals": true,
|
|
11
30
|
"noUnusedParameters": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
31
|
"noImplicitReturns": true,
|
|
14
32
|
"noImplicitThis": true,
|
|
15
33
|
"noImplicitAny": true,
|
|
@@ -19,13 +37,23 @@
|
|
|
19
37
|
"allowJs": true,
|
|
20
38
|
"baseUrl": ".",
|
|
21
39
|
"paths": {
|
|
22
|
-
"!maplibre-gl": [
|
|
40
|
+
"!maplibre-gl": [
|
|
41
|
+
"node_modules/maplibre-gl"
|
|
42
|
+
] // This mapping is relative to "baseUrl"
|
|
23
43
|
}
|
|
24
44
|
},
|
|
25
|
-
"include": [
|
|
26
|
-
|
|
45
|
+
"include": [
|
|
46
|
+
"src",
|
|
47
|
+
"src/custom.d.tsx"
|
|
48
|
+
],
|
|
49
|
+
"exclude": [
|
|
50
|
+
"node_modules",
|
|
51
|
+
"lib"
|
|
52
|
+
],
|
|
27
53
|
"typedocOptions": {
|
|
28
|
-
"entryPoints": [
|
|
54
|
+
"entryPoints": [
|
|
55
|
+
"src/index.ts"
|
|
56
|
+
],
|
|
29
57
|
"out": "docs",
|
|
30
58
|
}
|
|
31
|
-
}
|
|
59
|
+
}
|