@mapcomponents/react-maplibre 0.1.45 → 0.1.49
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 +23 -0
- package/README.md +61 -150
- package/coverage/clover.xml +350 -269
- package/coverage/coverage-final.json +11 -9
- package/coverage/lcov-report/index.html +95 -80
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +61 -31
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +17 -17
- 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 +72 -66
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +188 -53
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +21 -21
- 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 +2 -2
- 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 +265 -0
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +116 -0
- 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 +232 -0
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +25 -10
- 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 +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 +74 -20
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +19 -19
- 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 +80 -20
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +21 -21
- 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 +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 +19 -19
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +95 -71
- 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 +2 -2
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +12 -6
- package/coverage/lcov.info +688 -497
- 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 +75 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.test.d.ts +1 -0
- package/dist/components/MlBasicComponent.d.ts +5 -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 +69 -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 +9 -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 +68 -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 +24 -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 +193 -60
- 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/public/catalogue/mc_meta.json +1 -0
- package/public/thumbnails/MlMeasureTool.png +0 -0
- package/src/components/MapLibreMap/MapLibreMap.stories.js +75 -20
- package/src/components/MapLibreMap/MapLibreMap.tsx +12 -2
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +2 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +1 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +3 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +40 -38
- package/src/components/MlFeatureEditor/lib/utils.js +1 -2
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +1 -1
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +82 -37
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +1 -1
- package/src/components/MlMeasureTool/MlMeasureTool.doc.de.md +3 -0
- package/src/components/MlMeasureTool/MlMeasureTool.meta.json +15 -0
- package/src/components/MlMeasureTool/MlMeasureTool.stories.js +96 -0
- package/src/components/MlMeasureTool/MlMeasureTool.tsx +60 -0
- package/src/components/MlOsmLayer/{MlOsmLayer.stories.js → MlOsmLayer.stories_.js} +0 -0
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +26 -8
- package/src/components/MlWmsLayer/MlWmsLayer.stories.js +2 -3
- package/src/components/MlWmsLayer/MlWmsLayer.tsx +27 -7
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -1
- package/src/hooks/useLayer.test.js +205 -0
- package/src/hooks/useLayer.ts +15 -7
- package/src/hooks/useWms.js +1 -1
- package/src/index.ts +5 -4
- package/src/util/layerRemovalTest.js +5 -0
- package/tsconfig.json +35 -7
- package/docs-build/0.20735a16c2ad9677fe7d.manager.bundle.js +0 -1
- package/docs-build/0.b1b9b035.iframe.bundle.js +0 -2
- package/docs-build/0.b1b9b035.iframe.bundle.js.map +0 -1
- package/docs-build/1.c50fb367.iframe.bundle.js +0 -10
- package/docs-build/1.c50fb367.iframe.bundle.js.map +0 -1
- package/docs-build/17.2e544968.iframe.bundle.js +0 -2
- package/docs-build/17.2e544968.iframe.bundle.js.map +0 -1
- package/docs-build/18.42087006.iframe.bundle.js +0 -17
- package/docs-build/18.42087006.iframe.bundle.js.map +0 -1
- package/docs-build/19.7e782442.iframe.bundle.js +0 -14
- package/docs-build/19.7e782442.iframe.bundle.js.map +0 -1
- package/docs-build/2.e58dc625.iframe.bundle.js +0 -2
- package/docs-build/2.e58dc625.iframe.bundle.js.map +0 -1
- package/docs-build/20.f009289a.iframe.bundle.js +0 -2
- package/docs-build/20.f009289a.iframe.bundle.js.map +0 -1
- package/docs-build/21.1cdc9040.iframe.bundle.js +0 -4
- package/docs-build/21.1cdc9040.iframe.bundle.js.map +0 -1
- package/docs-build/22.c9e6b2d7.iframe.bundle.js +0 -22
- package/docs-build/22.c9e6b2d7.iframe.bundle.js.map +0 -1
- package/docs-build/3.a8172b89.iframe.bundle.js +0 -2
- package/docs-build/3.a8172b89.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.edd86ba9.iframe.bundle.js +0 -2
- package/docs-build/main~24120820.edd86ba9.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/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.2054ae7c.iframe.bundle.js +0 -8
- package/docs-build/vendors~main~0ad7406a.2054ae7c.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~0f485567.de36692f.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~0f485567.de36692f.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~41a6ab2c.a947ed53.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~41a6ab2c.a947ed53.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js +0 -8
- package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~57c1f6cb.6a433835.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~57c1f6cb.6a433835.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~73914085.a8e03e3b.iframe.bundle.js +0 -293
- package/docs-build/vendors~main~73914085.a8e03e3b.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~9c5b28f6.7b8beed1.iframe.bundle.js +0 -7
- package/docs-build/vendors~main~9c5b28f6.7b8beed1.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b5906859.7f66dcaf.iframe.bundle.js +0 -21
- package/docs-build/vendors~main~b5906859.7f66dcaf.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b8f44717.7053e467.iframe.bundle.js +0 -89
- package/docs-build/vendors~main~b8f44717.7053e467.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b9cf3951.a4fd68f5.iframe.bundle.js +0 -63
- package/docs-build/vendors~main~b9cf3951.a4fd68f5.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~d939e436.ba1cad1b.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~d939e436.ba1cad1b.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~f420d588.59c93444.iframe.bundle.js +0 -107
- package/docs-build/vendors~main~f420d588.59c93444.iframe.bundle.js.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import MlMeasureTool from "./MlMeasureTool";
|
|
4
|
+
|
|
5
|
+
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
6
|
+
import StraightenOutlinedIcon from "@mui/icons-material/StraightenOutlined";
|
|
7
|
+
import SquareFootOutlinedIcon from "@mui/icons-material/SquareFootOutlined";
|
|
8
|
+
import Grid from "@mui/material/Grid";
|
|
9
|
+
import Box from "@mui/material/Box";
|
|
10
|
+
import { MenuItem, Select } from "@mui/material";
|
|
11
|
+
|
|
12
|
+
const storyoptions = {
|
|
13
|
+
title: "MapComponents/MlMeasureTool",
|
|
14
|
+
component: MlMeasureTool,
|
|
15
|
+
argTypes: {},
|
|
16
|
+
decorators: mapContextDecorator,
|
|
17
|
+
};
|
|
18
|
+
export default storyoptions;
|
|
19
|
+
|
|
20
|
+
const Template = (args) => {
|
|
21
|
+
const [unit, setUnit] = useState("kilometers");
|
|
22
|
+
const handleChange = (event) => {
|
|
23
|
+
setUnit(event.target.value);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div style={{ width: "200px", position: "absolute", zIndex: 105 }}>
|
|
28
|
+
<Select
|
|
29
|
+
name={"units"}
|
|
30
|
+
onChange={handleChange}
|
|
31
|
+
label={"Unit for measurement"}
|
|
32
|
+
defaultValue={"kilometers"}
|
|
33
|
+
>
|
|
34
|
+
<MenuItem value={"kilometers"}>Kilometers</MenuItem>
|
|
35
|
+
<MenuItem value={"miles"}>Miles</MenuItem>
|
|
36
|
+
</Select>
|
|
37
|
+
<Grid
|
|
38
|
+
container
|
|
39
|
+
style={{
|
|
40
|
+
textAlign: "left",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<SquareFootOutlinedIcon />
|
|
45
|
+
<h4 style={{ margin: "0px" }}>Measure Polygon</h4>
|
|
46
|
+
</Grid>
|
|
47
|
+
|
|
48
|
+
<Box m={2} style={{ textAlign: "left" }}>
|
|
49
|
+
Area: <MlMeasureTool measureType={"polygon"} unit={unit} />
|
|
50
|
+
</Box>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const LineTemplate = (args) => {
|
|
56
|
+
const [unit, setUnit] = useState("kilometers");
|
|
57
|
+
const handleChange = (event) => {
|
|
58
|
+
setUnit(event.target.value);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div style={{ width: "200px", position: "absolute", zIndex: 105 }}>
|
|
63
|
+
<Select
|
|
64
|
+
name={"units"}
|
|
65
|
+
onChange={handleChange}
|
|
66
|
+
label={"Unit for measurement"}
|
|
67
|
+
defaultValue={"kilometers"}
|
|
68
|
+
>
|
|
69
|
+
<MenuItem value={"kilometers"}> Kilometers</MenuItem>
|
|
70
|
+
<MenuItem value={"miles"}> Miles</MenuItem>
|
|
71
|
+
</Select>
|
|
72
|
+
<Grid
|
|
73
|
+
container
|
|
74
|
+
style={{
|
|
75
|
+
textAlign: "left",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<StraightenOutlinedIcon />
|
|
80
|
+
<h4 style={{ margin: "0px" }}>Measure Line</h4>
|
|
81
|
+
</Grid>
|
|
82
|
+
|
|
83
|
+
<Box m={2} style={{ textAlign: "left" }}>
|
|
84
|
+
Length: <MlMeasureTool measureType={"line"} unit={unit} />
|
|
85
|
+
</Box>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const MeasureLine = LineTemplate.bind({});
|
|
91
|
+
MeasureLine.parameters = {};
|
|
92
|
+
MeasureLine.args = {};
|
|
93
|
+
|
|
94
|
+
export const MeasurePolygon = Template.bind({});
|
|
95
|
+
MeasurePolygon.parameters = {};
|
|
96
|
+
MeasurePolygon.args = {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import MlFeatureEditor from "../MlFeatureEditor/MlFeatureEditor";
|
|
3
|
+
import * as turf from "@turf/turf";
|
|
4
|
+
|
|
5
|
+
interface MlMeasureToolProps {
|
|
6
|
+
/**
|
|
7
|
+
* String that specify if the Tool measures an area ("polygon") or length ("line")
|
|
8
|
+
*/
|
|
9
|
+
measureType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* String that dictates which unit of measurement is used
|
|
12
|
+
*/
|
|
13
|
+
unit?: turf.Units;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//const unitSquareConvert = {
|
|
17
|
+
// kilometers: 1,
|
|
18
|
+
// miles: 1 / 2.58998811,
|
|
19
|
+
//};
|
|
20
|
+
function getUnitSquareMultiplier(measureType:string | undefined) {
|
|
21
|
+
return measureType === "miles" ? 1 / 2.58998811 : 1;
|
|
22
|
+
}
|
|
23
|
+
function getUnitLabel(measureType:string | undefined) {
|
|
24
|
+
return measureType === "miles" ? 'mi' : 'km';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const MlMeasureTool = (props: MlMeasureToolProps) => {
|
|
28
|
+
const [length, setLength] = useState(0);
|
|
29
|
+
const [currentFeatures, setCurrentFeatures] = useState([undefined]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (currentFeatures[0]) {
|
|
33
|
+
setLength(
|
|
34
|
+
props.measureType === "polygon"
|
|
35
|
+
? (turf.area(currentFeatures[0]) / 1000000) * getUnitSquareMultiplier(props.unit)
|
|
36
|
+
: turf.length(currentFeatures[0], { units: props.unit })
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}, [props.unit, currentFeatures]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<MlFeatureEditor
|
|
44
|
+
onChange={(features:any) => {
|
|
45
|
+
setCurrentFeatures(features);
|
|
46
|
+
}}
|
|
47
|
+
mode={props.measureType === "polygon" ? "custom_polygon" : "draw_line_string"}
|
|
48
|
+
/>
|
|
49
|
+
{length.toFixed(2)} {getUnitLabel(props.unit)}
|
|
50
|
+
{props.measureType === "polygon" ? "²" : ""}
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
MlMeasureTool.defaultProps = {
|
|
56
|
+
mapId: undefined,
|
|
57
|
+
measureType: "line",
|
|
58
|
+
unit: "kilometers",
|
|
59
|
+
};
|
|
60
|
+
export default MlMeasureTool;
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from "react";
|
|
1
|
+
import React, { useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import useMap from "../../hooks/useMap";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
|
|
@@ -24,18 +24,20 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const layerIdsRef = useRef({});
|
|
27
|
-
const layerId = useRef(
|
|
28
|
-
props.layerId || "MlVectorTileLayer-" + mapHook.componentId
|
|
29
|
-
);
|
|
27
|
+
const layerId = useRef(props.layerId || "MlVectorTileLayer-" + mapHook.componentId);
|
|
30
28
|
const layerPaintConfsRef = useRef({});
|
|
31
29
|
const layerLayoutConfsRef = useRef({});
|
|
32
30
|
const initializedRef = useRef(false);
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
if (!mapHook.map
|
|
32
|
+
const createLayer = useCallback(() => {
|
|
33
|
+
if (!mapHook.map) return;
|
|
36
34
|
|
|
37
35
|
initializedRef.current = true;
|
|
38
36
|
|
|
37
|
+
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
38
|
+
mapHook.cleanup();
|
|
39
|
+
}
|
|
40
|
+
|
|
39
41
|
// Add the new layer to the openlayers instance once it is available
|
|
40
42
|
mapHook.map.addSource(
|
|
41
43
|
layerId.current,
|
|
@@ -72,12 +74,28 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
|
|
|
72
74
|
mapHook.componentId
|
|
73
75
|
);
|
|
74
76
|
layerPaintConfsRef.current[key] = JSON.stringify(props.layers[key].paint);
|
|
75
|
-
layerLayoutConfsRef.current[key] = JSON.stringify(
|
|
76
|
-
|
|
77
|
+
layerLayoutConfsRef.current[key] = JSON.stringify(props.layers[key].layout);
|
|
78
|
+
|
|
79
|
+
// recreate layer if style has changed
|
|
80
|
+
mapHook.map.on(
|
|
81
|
+
"styledata",
|
|
82
|
+
() => {
|
|
83
|
+
if (initializedRef.current && !mapHook.map?.map.getSource(layerId.current)) {
|
|
84
|
+
console.log("Recreate Layer " + layerId.current);
|
|
85
|
+
createLayer();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
mapHook.componentId
|
|
77
89
|
);
|
|
78
90
|
}
|
|
79
91
|
}, [mapHook.map, props]);
|
|
80
92
|
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (initializedRef.current) return;
|
|
95
|
+
|
|
96
|
+
createLayer();
|
|
97
|
+
}, [createLayer]);
|
|
98
|
+
|
|
81
99
|
useEffect(() => {
|
|
82
100
|
if (!mapHook.map || !initializedRef.current) return;
|
|
83
101
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
@@ -4,7 +4,7 @@ import MlWmsLayer from "./MlWmsLayer";
|
|
|
4
4
|
import TopToolbar from "../../ui_components/TopToolbar";
|
|
5
5
|
import Button from "@mui/material/Button";
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
8
8
|
|
|
9
9
|
import "../../App.css";
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ const storyoptions = {
|
|
|
15
15
|
url: {},
|
|
16
16
|
layer: {},
|
|
17
17
|
},
|
|
18
|
-
decorators:
|
|
18
|
+
decorators: mapContextDecorator,
|
|
19
19
|
};
|
|
20
20
|
export default storyoptions;
|
|
21
21
|
|
|
@@ -41,7 +41,6 @@ const Template = (props) => {
|
|
|
41
41
|
export const ExampleConfig = Template.bind({});
|
|
42
42
|
ExampleConfig.parameters = {};
|
|
43
43
|
ExampleConfig.args = {
|
|
44
|
-
mapId: "map_2",
|
|
45
44
|
url: "https://www.wms.nrw.de/geobasis/wms_nw_uraufnahme",
|
|
46
45
|
urlParameters: {
|
|
47
46
|
layers: "nw_uraufnahme_rw",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from "react";
|
|
1
|
+
import React, { useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import useMap from "../../hooks/useMap";
|
|
3
3
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
@@ -54,7 +54,7 @@ interface MlWmsLayerProps {
|
|
|
54
54
|
*
|
|
55
55
|
* @component
|
|
56
56
|
*/
|
|
57
|
-
const MlWmsLayer = (props:MlWmsLayerProps) => {
|
|
57
|
+
const MlWmsLayer = (props: MlWmsLayerProps) => {
|
|
58
58
|
const mapHook = useMap({
|
|
59
59
|
mapId: props.mapId,
|
|
60
60
|
waitForLayer: props.insertBeforeLayer,
|
|
@@ -63,11 +63,15 @@ const MlWmsLayer = (props:MlWmsLayerProps) => {
|
|
|
63
63
|
const initializedRef = useRef(false);
|
|
64
64
|
const layerId = useRef(props.layerId || "MlWmsLayer-" + mapHook.componentId);
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
if (!mapHook.map
|
|
66
|
+
const createLayer = useCallback(() => {
|
|
67
|
+
if (!mapHook.map) return;
|
|
68
68
|
|
|
69
69
|
initializedRef.current = true;
|
|
70
70
|
|
|
71
|
+
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
72
|
+
mapHook.cleanup();
|
|
73
|
+
}
|
|
74
|
+
|
|
71
75
|
let _propsUrlParams;
|
|
72
76
|
let _wmsUrl = props.url;
|
|
73
77
|
if (props.url.indexOf("?") !== -1) {
|
|
@@ -83,8 +87,7 @@ const MlWmsLayer = (props:MlWmsLayerProps) => {
|
|
|
83
87
|
};
|
|
84
88
|
let urlParams = new URLSearchParams(urlParamsObj);
|
|
85
89
|
let urlParamsStr =
|
|
86
|
-
decodeURIComponent(urlParams.toString()) +
|
|
87
|
-
"".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
90
|
+
decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
88
91
|
|
|
89
92
|
mapHook.map.addSource(
|
|
90
93
|
layerId.current,
|
|
@@ -109,10 +112,27 @@ const MlWmsLayer = (props:MlWmsLayerProps) => {
|
|
|
109
112
|
mapHook.componentId
|
|
110
113
|
);
|
|
111
114
|
|
|
115
|
+
// recreate layer if map style.json has changed
|
|
116
|
+
mapHook.map.on(
|
|
117
|
+
"styledata",
|
|
118
|
+
() => {
|
|
119
|
+
if (initializedRef.current && !mapHook.map?.map.getLayer(layerId.current)) {
|
|
120
|
+
console.log("Recreate Layer " + layerId.current);
|
|
121
|
+
createLayer();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
mapHook.componentId
|
|
125
|
+
);
|
|
112
126
|
if (!props.visible) {
|
|
113
127
|
mapHook.map.map.setLayoutProperty(layerId.current, "visibility", "none");
|
|
114
128
|
}
|
|
115
|
-
}, [mapHook, props]);
|
|
129
|
+
}, [mapHook.map, props]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (initializedRef.current) return;
|
|
133
|
+
|
|
134
|
+
createLayer();
|
|
135
|
+
}, [createLayer]);
|
|
116
136
|
|
|
117
137
|
useEffect(() => {
|
|
118
138
|
if (!mapHook.map || !initializedRef.current) return;
|
|
@@ -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
|
@@ -60,7 +60,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
60
60
|
if (!mapHook.map) return;
|
|
61
61
|
|
|
62
62
|
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
63
|
-
mapHook.
|
|
63
|
+
mapHook.cleanup();
|
|
64
64
|
}
|
|
65
65
|
if (mapHook.map.map.getSource(layerId.current)) {
|
|
66
66
|
mapHook.map.map.removeSource(layerId.current);
|
|
@@ -102,6 +102,18 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
102
102
|
mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// recreate layer if style has changed
|
|
106
|
+
mapHook.map.on(
|
|
107
|
+
"styledata",
|
|
108
|
+
() => {
|
|
109
|
+
if (initializedRef.current && !mapHook.map?.map.getLayer(layerId.current)) {
|
|
110
|
+
console.log("Recreate Layer");
|
|
111
|
+
createLayer();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
mapHook.componentId
|
|
115
|
+
);
|
|
116
|
+
|
|
105
117
|
layerPaintConfRef.current = JSON.stringify(props.options?.paint);
|
|
106
118
|
layerLayoutConfRef.current = JSON.stringify(props.options?.layout);
|
|
107
119
|
layerTypeRef.current = props.options.type;
|
|
@@ -164,14 +176,10 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
164
176
|
}
|
|
165
177
|
}, [props.options, mapHook.map]);
|
|
166
178
|
|
|
167
|
-
const cleanup = () => {
|
|
168
|
-
initializedRef.current = false;
|
|
169
|
-
mapHook.cleanup();
|
|
170
|
-
};
|
|
171
|
-
|
|
172
179
|
useEffect(() => {
|
|
173
180
|
return () => {
|
|
174
|
-
|
|
181
|
+
initializedRef.current = false;
|
|
182
|
+
mapHook.cleanup();
|
|
175
183
|
};
|
|
176
184
|
}, []);
|
|
177
185
|
|
package/src/hooks/useWms.js
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as MlFillExtrusionLayer } from "./components/MlFillExtrusionLay
|
|
|
6
6
|
export { default as MlFollowGps } from "./components/MlFollowGps/MlFollowGps";
|
|
7
7
|
export { default as MlGeoJsonLayer } from "./components/MlGeoJsonLayer/MlGeoJsonLayer";
|
|
8
8
|
export { default as MlImageMarkerLayer } from "./components/MlImageMarkerLayer/MlImageMarkerLayer";
|
|
9
|
+
export { default as MlMeasureTool } from "./components/MlMeasureTool/MlMeasureTool";
|
|
9
10
|
export { default as MlNavigationTools } from "./components/MlNavigationTools/MlNavigationTools";
|
|
10
11
|
export { default as MlNavigationCompass } from "./components/MlNavigationCompass/MlNavigationCompass";
|
|
11
12
|
export { default as MlLayer } from "./components/MlLayer/MlLayer";
|
|
@@ -32,7 +33,7 @@ export { default as useMapState } from "./hooks/useMapState";
|
|
|
32
33
|
export { default as useMap } from "./hooks/useMap";
|
|
33
34
|
export { default as useWms } from "./hooks/useWms.js";
|
|
34
35
|
|
|
35
|
-
export { MapComponentsProvider } from
|
|
36
|
-
export { default as MapContext } from
|
|
37
|
-
export { default as SimpleDataProvider } from
|
|
38
|
-
export { default as SimpleDataContext } from
|
|
36
|
+
export { MapComponentsProvider } from "./contexts/MapContext";
|
|
37
|
+
export { default as MapContext } from "./contexts/MapContext";
|
|
38
|
+
export { default as SimpleDataProvider } from "./contexts/SimpleDataProvider";
|
|
39
|
+
export { default as SimpleDataContext } from "./contexts/SimpleDataContext";
|
|
@@ -75,6 +75,11 @@ const layerRemovalTest = (
|
|
|
75
75
|
|
|
76
76
|
wrapper.find(".trigger_refresh").simulate("click");
|
|
77
77
|
|
|
78
|
+
// debug helper
|
|
79
|
+
//console.log('layer removal test')
|
|
80
|
+
//console.log(wrapper.find(".layers_json").text());
|
|
81
|
+
//console.log(regexLayerNameTest.toString());
|
|
82
|
+
//console.log(regexLayerNameTest.test(wrapper.find(".layers_json").text()));
|
|
78
83
|
expect(regexLayerNameTest.test(wrapper.find(".layers_json").text())).toEqual(
|
|
79
84
|
true
|
|
80
85
|
);
|