@mapcomponents/react-maplibre 0.1.46 → 0.1.51
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 +35 -0
- package/README.md +61 -150
- package/coverage/clover.xml +233 -226
- package/coverage/coverage-final.json +9 -9
- package/coverage/lcov-report/index.html +34 -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/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 +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 +103 -22
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +15 -15
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/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 +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 +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 +2 -2
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +5 -2
- package/coverage/lcov.info +464 -443
- 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/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 +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 +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 +66 -24
- 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/src/components/MapLibreMap/MapLibreMap.tsx +1 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +4 -3
- 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/MlGeoJsonLayer/MlGeoJsonLayer.tsx +14 -9
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +2 -1
- package/src/components/MlMeasureTool/MlMeasureTool.stories.js +68 -39
- package/src/components/MlMeasureTool/MlMeasureTool.tsx +38 -11
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +18 -17
- 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 +11 -8
- package/src/hooks/useWms.js +1 -1
- package/src/index.ts +1 -0
- package/tsconfig.json +35 -7
- package/docs-build/0.0ee4f98c.iframe.bundle.js +0 -2
- package/docs-build/0.0ee4f98c.iframe.bundle.js.map +0 -1
- package/docs-build/0.20735a16c2ad9677fe7d.manager.bundle.js +0 -1
- package/docs-build/1.bb3cf738.iframe.bundle.js +0 -10
- package/docs-build/1.bb3cf738.iframe.bundle.js.map +0 -1
- package/docs-build/17.97db5b3f.iframe.bundle.js +0 -2
- package/docs-build/17.97db5b3f.iframe.bundle.js.map +0 -1
- package/docs-build/18.f8d843df.iframe.bundle.js +0 -17
- package/docs-build/18.f8d843df.iframe.bundle.js.map +0 -1
- package/docs-build/19.c45e6b08.iframe.bundle.js +0 -14
- package/docs-build/19.c45e6b08.iframe.bundle.js.map +0 -1
- package/docs-build/2.42c790e4.iframe.bundle.js +0 -2
- package/docs-build/2.42c790e4.iframe.bundle.js.map +0 -1
- package/docs-build/20.120bbcfb.iframe.bundle.js +0 -2
- package/docs-build/20.120bbcfb.iframe.bundle.js.map +0 -1
- package/docs-build/21.37c885f1.iframe.bundle.js +0 -4
- package/docs-build/21.37c885f1.iframe.bundle.js.map +0 -1
- package/docs-build/22.7fbc99f4.iframe.bundle.js +0 -22
- package/docs-build/22.7fbc99f4.iframe.bundle.js.map +0 -1
- package/docs-build/3.1a37a83e.iframe.bundle.js +0 -2
- package/docs-build/3.1a37a83e.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.905c51c8.iframe.bundle.js +0 -2
- package/docs-build/main~24120820.905c51c8.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.93aea1be.iframe.bundle.js +0 -8
- package/docs-build/vendors~main~0ad7406a.93aea1be.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~0f485567.6e7163ef.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~0f485567.6e7163ef.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~41a6ab2c.da377733.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~41a6ab2c.da377733.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.86178471.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~57c1f6cb.86178471.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~73914085.e2f34f8e.iframe.bundle.js +0 -293
- package/docs-build/vendors~main~73914085.e2f34f8e.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~9c5b28f6.eefa7445.iframe.bundle.js +0 -7
- package/docs-build/vendors~main~9c5b28f6.eefa7445.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b5906859.210afc21.iframe.bundle.js +0 -21
- package/docs-build/vendors~main~b5906859.210afc21.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b8f44717.7b869975.iframe.bundle.js +0 -89
- package/docs-build/vendors~main~b8f44717.7b869975.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b9cf3951.62d39717.iframe.bundle.js +0 -63
- package/docs-build/vendors~main~b9cf3951.62d39717.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~d939e436.394e3bc7.iframe.bundle.js +0 -2
- package/docs-build/vendors~main~d939e436.394e3bc7.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~f420d588.88814a6a.iframe.bundle.js +0 -107
- package/docs-build/vendors~main~f420d588.88814a6a.iframe.bundle.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var uuid_regex: string;
|
|
2
|
+
export namespace mockMapLibreMethods {
|
|
3
|
+
const on: any;
|
|
4
|
+
const off: any;
|
|
5
|
+
const addControl: any;
|
|
6
|
+
const removeControl: any;
|
|
7
|
+
const hasControl: any;
|
|
8
|
+
function getCanvas(): HTMLCanvasElement;
|
|
9
|
+
function getContainer(): {
|
|
10
|
+
style: {};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Legend(props: any): JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const LoadingOverlayContext: React.Context<{}>;
|
|
2
|
+
export function LoadingOverlayProvider({ children }: {
|
|
3
|
+
children: any;
|
|
4
|
+
}): JSX.Element;
|
|
5
|
+
export namespace LoadingOverlayProvider {
|
|
6
|
+
namespace propTypes {
|
|
7
|
+
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
import React from "react";
|
|
11
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Sidebar(props: any): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Legend(props: any): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TopToolbar(props: any): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/react-maplibre",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"source": "src/index.ts",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "rollup -c",
|
|
10
11
|
"start": "start-storybook -p 6006 -s public",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"MlCreatePdfButton":{"name":"MlCreatePdfButton","title":"Export PDF","description":"Creates a PDF file with the current map view.","i18n":{"de":{"title":"PDF Export","description":"Erzeugt eine PDF Datei aus der aktuellen Kartenansicht."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlFeatureEditor":{"name":"MlFeatureEditor","title":"Sketch tools","description":"Enables the editing of Point, Linestring and Polygon GeoJSON Files.","i18n":{"de":{"title":"Skizzen Werkzeug","description":"Erzeugen und Bearbeiten von Objekten."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":0},"MlFillExtrusionLayer":{"name":"MlFillExtrusionLayer","title":"Simple 3D buildings","description":"Draws a level, out of the building outline and the height, extrudes 3D Objects as buildings.","i18n":{"de":{"title":"3D Gebäude","description":"Zeichnet eine Ebene mit einfach, aus den Gebäudeumrissen und anhand der Höhen, extrudierten 3D Objekten als Gebäude."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlFollowGps":{"name":"MlFollowGps","title":"GPS tracker","description":"","i18n":{"de":{"title":"GPS-Tracker","description":""}},"tags":[],"category":"","type":"component","price":0},"MlGeoJsonLayer":{"name":"MlGeoJsonLayer","title":"GeoJSON layer","description":"","i18n":{"de":{"title":"GeoJSON Darstellung","description":""}},"tags":[],"category":"","type":"component","price":0},"MlGPXViewer":{"name":"MlGPXViewer","title":"GPX viewer","description":"","i18n":{"de":{"title":"GPX Darstellung","description":""}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlLayerMagnify":{"name":"MlLayerMagnify","title":"Map magnifier","description":"Hides a part of a map that is superimposed on another MapLibre map.","i18n":{"de":{"title":"Kartenlupe","description":"Kartenlupe blendet einen Teil einer, von zwei übereinanderliegenden, MapLibre Karten aus."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlLayerSwipe":{"name":"MlLayerSwipe","title":"Map curtain","description":"Map curtain hides an area of the top one of two overlaying MapLibre maps.","i18n":{"de":{"title":"Kartenvorhang","description":"Kartenvorhangs blendet einen Teil einer, von zwei übereinanderliegenden, MapLibre Karten aus."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlMeasureTool":{"name":"MlMeasureTool","title":"Measure tool","description":"","i18n":{"de":{"title":"Messwerkzeug","description":""}},"tags":[],"category":"","type":"component","price":0},"MlNavigationCompass":{"name":"MlNavigationCompass","title":"Compass","description":"","i18n":{"de":{"title":"Kompass","description":""}},"tags":[],"category":"","type":"component","price":0},"MlNavigationTools":{"name":"MlNavigationTools","title":"Navigation tools","description":"","i18n":{"de":{"title":"Navigationswerkzeuge","description":""}},"tags":[],"category":"","type":"component","price":0},"MlScaleReference":{"name":"MlScaleReference","title":"Reference scale","description":"","i18n":{"de":{"title":"Maßstabsreferenz","description":""}},"tags":[],"category":"","type":"component","price":0},"MlSpatialElevationProfile":{"name":"MlSpatialElevationProfile","title":"3D height profile","description":"Draws a level, out of the building outline and the height, extrudes 3D Objects as buildings.","i18n":{"de":{"title":"3D Höhenprofil","description":"Zeichnet eine Ebene mit einfach, aus den Gebäudeumrissen und anhand der Höhen, extrudierten 3D Objekten als Gebäude."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlThreeJsLayer":{"name":"MlThreeJsLayer","title":"3D Model","description":"Layer Component, that makes it possible to show 3D Models on the map.","i18n":{"de":{"title":"3D Modelle","description":"Layer Component, das es ermöglicht 3D Modelle auf der Karte darzustellen."}},"tags":["Map layer"],"category":"layer","type":"component","price":5000},"MlTransitionGeoJsonLayer":{"name":"MlTransitionGeoJsonLayer","title":"GeoJSON layer","description":"","i18n":{"de":{"title":"GeoJSON Ebene","description":""}},"tags":[],"category":"","type":"component","price":0},"MlVectorTileLayer":{"name":"MlVectorTileLayer","title":"Vector tile layer","description":"Adds a vector tile layer to the map","i18n":{"de":{"title":"Vector Tiles","description":"Baustein: Vektorenkacheln/Vector Tiles (der Anwendung/Karte hinzufügen)"}},"tags":["Map layer"],"category":"layer","type":"component","price":5000},"MlWmsLoader":{"name":"MlWmsLoader","title":"WMS loader","description":"","i18n":{"de":{"title":"WMS Feature Info","description":""}},"tags":[],"category":"","type":"component","price":0}}
|
|
@@ -16,7 +16,7 @@ type MapLibreMapProps = {
|
|
|
16
16
|
* See https://maplibre.org/maplibre-gl-js-docs/api/map/ for a formal documentation of al
|
|
17
17
|
* available properties.
|
|
18
18
|
*/
|
|
19
|
-
options?: MapOptionsType
|
|
19
|
+
options?: Partial<MapOptionsType>;
|
|
20
20
|
/**
|
|
21
21
|
* css style definition passed to the map container DOM element
|
|
22
22
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Map, IControl, MapOptions as MapOptionsType
|
|
1
|
+
import { Map, IControl, MapOptions as MapOptionsType, } from "!maplibre-gl";
|
|
2
|
+
import { Map as MapType } from "maplibre-gl";
|
|
2
3
|
|
|
3
4
|
type EventArgArray = [string, string | Function, Function?];
|
|
4
5
|
type LayerState = {
|
|
@@ -53,7 +54,7 @@ class MapLibreGlWrapper {
|
|
|
53
54
|
};
|
|
54
55
|
initRegisteredElements: Function;
|
|
55
56
|
addNativeMaplibreFunctionsAndProps: Function;
|
|
56
|
-
map:
|
|
57
|
+
map: MapType;
|
|
57
58
|
style: object;
|
|
58
59
|
|
|
59
60
|
styleJson: object;
|
|
@@ -603,7 +604,7 @@ class MapLibreGlWrapper {
|
|
|
603
604
|
});
|
|
604
605
|
}
|
|
605
606
|
|
|
606
|
-
self.map = new Map(props.mapOptions);
|
|
607
|
+
self.map = new Map(props.mapOptions) as MapType;
|
|
607
608
|
//@ts-ignore
|
|
608
609
|
window._map = self.map;
|
|
609
610
|
|
|
@@ -82,7 +82,7 @@ describe("<MlFeatureEditor>", () => {
|
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
// MapLibreGlWrapper now subscribes to "data", "move" events on its own
|
|
85
|
-
await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(
|
|
85
|
+
await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(7));
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
it("should deregister 2 event listeners to the maplibre instance", async () => {
|
|
@@ -93,11 +93,11 @@ describe("<MlFeatureEditor>", () => {
|
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
// MapLibreGlWrapper now subscribes to "data", "move" events on its own
|
|
96
|
-
expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(
|
|
96
|
+
expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(7);
|
|
97
97
|
|
|
98
98
|
wrapper.find(".toggle_layer_visible").simulate("click");
|
|
99
99
|
|
|
100
|
-
expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(
|
|
100
|
+
expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(3);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it("should add MapBox-Gl-draw instance using map.addControl to the maplibre instance", async () => {
|
|
@@ -9,26 +9,25 @@ import CustomDirectSelectMode from "./custom-direct-select-mode.js";
|
|
|
9
9
|
|
|
10
10
|
import useMap from "../../hooks/useMap";
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
interface MlFeatureEditorProps {
|
|
14
13
|
/**
|
|
15
14
|
* Id of the target MapLibre instance in mapContext
|
|
16
15
|
*/
|
|
17
|
-
mapId
|
|
16
|
+
mapId?: string;
|
|
18
17
|
/**
|
|
19
18
|
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
20
19
|
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
21
20
|
*/
|
|
22
|
-
insertBeforeLayer
|
|
21
|
+
insertBeforeLayer?: string;
|
|
23
22
|
/**
|
|
24
23
|
* Input GeoJson data at initialization
|
|
25
24
|
*/
|
|
26
|
-
geojson
|
|
25
|
+
geojson?: any;
|
|
27
26
|
/**
|
|
28
27
|
* Callback function that is called each time the GeoJson data within has changed within MlFeatureEditor.
|
|
29
28
|
* First parameter is the new GeoJson feature.
|
|
30
29
|
*/
|
|
31
|
-
onChange?: Function
|
|
30
|
+
onChange?: Function;
|
|
32
31
|
/**
|
|
33
32
|
* Feature editor mode:
|
|
34
33
|
* - "custom_select" edit features
|
|
@@ -36,40 +35,30 @@ interface MlFeatureEditorProps {
|
|
|
36
35
|
* - "draw_point" draw Point
|
|
37
36
|
* - "draw_line_string" draw LineString
|
|
38
37
|
*/
|
|
39
|
-
mode?:string
|
|
38
|
+
mode?: string;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* GeoJson Feature editor that allows to create or manipulate GeoJson data
|
|
44
43
|
*/
|
|
45
|
-
const MlFeatureEditor = (props:MlFeatureEditorProps) => {
|
|
44
|
+
const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
46
45
|
const draw = useRef<MapboxDraw>();
|
|
47
46
|
const mapHook = useMap({
|
|
48
47
|
mapId: props.mapId,
|
|
49
48
|
waitForLayer: props.insertBeforeLayer,
|
|
50
49
|
});
|
|
51
|
-
const onChangeRef = useRef(props.onChange);
|
|
52
50
|
|
|
53
51
|
const drawToolsInitialized = useRef(false);
|
|
54
52
|
const [drawToolsReady, setDrawToolsReady] = useState(false);
|
|
55
53
|
|
|
56
|
-
const [mouseUpTrigger, setMouseUpTrigger] = useState(0);
|
|
57
54
|
|
|
58
|
-
const modeChangeHandler = (e:any) => {
|
|
55
|
+
const modeChangeHandler = (e: any) => {
|
|
59
56
|
console.log("MlFeatureEditor mode change to " + e.mode);
|
|
60
57
|
//setDrawMode(e.mode);
|
|
61
58
|
};
|
|
62
59
|
|
|
63
|
-
const mouseUpHandler = () => {
|
|
64
|
-
setMouseUpTrigger(Math.random());
|
|
65
|
-
};
|
|
66
|
-
|
|
67
60
|
useEffect(() => {
|
|
68
|
-
if (
|
|
69
|
-
mapHook.map &&
|
|
70
|
-
!drawToolsInitialized.current
|
|
71
|
-
) {
|
|
72
|
-
|
|
61
|
+
if (mapHook.map && !drawToolsInitialized.current) {
|
|
73
62
|
drawToolsInitialized.current = true;
|
|
74
63
|
|
|
75
64
|
if (
|
|
@@ -96,34 +85,47 @@ const MlFeatureEditor = (props:MlFeatureEditorProps) => {
|
|
|
96
85
|
),
|
|
97
86
|
});
|
|
98
87
|
|
|
99
|
-
mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
|
|
100
|
-
|
|
101
88
|
mapHook.map.addControl(draw.current, "top-left", mapHook.componentId);
|
|
102
89
|
|
|
103
|
-
|
|
90
|
+
|
|
91
|
+
mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
|
|
104
92
|
|
|
105
93
|
setDrawToolsReady(true);
|
|
106
94
|
}
|
|
107
|
-
}, [mapHook.map,
|
|
95
|
+
}, [mapHook.map, props, drawToolsInitialized]);
|
|
108
96
|
|
|
109
97
|
useEffect(() => {
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
if (!mapHook.map || !drawToolsReady) return;
|
|
99
|
+
|
|
100
|
+
const changeHandler = () => {
|
|
101
|
+
if (draw.current) {
|
|
102
|
+
// update drawnFeatures state object
|
|
103
|
+
if (typeof props.onChange === "function") {
|
|
104
|
+
let currentFeatureCollection = draw.current.getAll?.();
|
|
105
|
+
props.onChange(currentFeatureCollection?.features);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
mapHook.map.on("mouseup", changeHandler);
|
|
111
|
+
|
|
112
|
+
mapHook.map.on("touchend", changeHandler);
|
|
113
|
+
|
|
114
|
+
return () => {
|
|
115
|
+
if (!mapHook.map) return;
|
|
116
|
+
|
|
117
|
+
mapHook.map.map.off("mouseup", changeHandler);
|
|
118
|
+
|
|
119
|
+
mapHook.map.map.off("touchend", changeHandler);
|
|
115
120
|
}
|
|
116
|
-
|
|
121
|
+
|
|
122
|
+
}, [drawToolsReady, mapHook.map])
|
|
117
123
|
|
|
118
124
|
useEffect(() => {
|
|
119
|
-
if (draw.current &&
|
|
120
|
-
|
|
121
|
-
let currentFeatureCollection = draw.current.getAll();
|
|
122
|
-
if (typeof onChangeRef.current === "function") {
|
|
123
|
-
onChangeRef.current(currentFeatureCollection.features);
|
|
124
|
-
}
|
|
125
|
+
if (draw.current && props.geojson?.geometry) {
|
|
126
|
+
draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
|
|
125
127
|
}
|
|
126
|
-
}, [
|
|
128
|
+
}, [props.geojson, drawToolsReady]);
|
|
127
129
|
|
|
128
130
|
useEffect(() => {
|
|
129
131
|
if (props.mode && draw.current) {
|
|
@@ -132,7 +134,7 @@ const MlFeatureEditor = (props:MlFeatureEditorProps) => {
|
|
|
132
134
|
}
|
|
133
135
|
}, [props.mode]);
|
|
134
136
|
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
+
return <></>;
|
|
138
|
+
};
|
|
137
139
|
|
|
138
140
|
export default MlFeatureEditor;
|
|
@@ -39,8 +39,7 @@ const drawUtils = {
|
|
|
39
39
|
getDrawInstance: (map) => {
|
|
40
40
|
for (var i = map._controls.length - 1; i >= 0; i--) {
|
|
41
41
|
if (
|
|
42
|
-
map._controls[i]
|
|
43
|
-
map._controls[i].options.defaultMode === "custom_select"
|
|
42
|
+
map._controls[i]?.modes?.SIMPLE_SELECT === "simple_select"
|
|
44
43
|
) {
|
|
45
44
|
return map._controls[i];
|
|
46
45
|
}
|
|
@@ -8,6 +8,9 @@ import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
|
8
8
|
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
9
9
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
import { LineLayerSpecification, CircleLayerSpecification, FillLayerSpecification,MapLayerMouseEvent, LayerSpecification } from "maplibre-gl";
|
|
13
|
+
|
|
11
14
|
type MlGeoJsonLayerProps = {
|
|
12
15
|
/**
|
|
13
16
|
* Id of the target MapLibre instance in mapContext
|
|
@@ -16,6 +19,8 @@ type MlGeoJsonLayerProps = {
|
|
|
16
19
|
/**
|
|
17
20
|
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
18
21
|
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
22
|
+
* This layer will not be added to the maplibre-gl instance until a layer with an
|
|
23
|
+
* id that matches the value of insertBeforeLayer is created.
|
|
19
24
|
*/
|
|
20
25
|
insertBeforeLayer?: string;
|
|
21
26
|
/**
|
|
@@ -30,7 +35,7 @@ type MlGeoJsonLayerProps = {
|
|
|
30
35
|
* Type of the layer that will be added to the MapLibre instance.
|
|
31
36
|
* Possible values: "line", "circle", "fill"
|
|
32
37
|
*/
|
|
33
|
-
type?:
|
|
38
|
+
type?: "fill" | "line" | "circle";
|
|
34
39
|
/**
|
|
35
40
|
* Paint property object, that is passed to the addLayer call.
|
|
36
41
|
* Possible props depend on the layer type.
|
|
@@ -38,7 +43,7 @@ type MlGeoJsonLayerProps = {
|
|
|
38
43
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
39
44
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
40
45
|
*/
|
|
41
|
-
paint?:
|
|
46
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['layout'];
|
|
42
47
|
/**
|
|
43
48
|
* Layout property object, that is passed to the addLayer call.
|
|
44
49
|
* Possible props depend on the layer type.
|
|
@@ -46,28 +51,28 @@ type MlGeoJsonLayerProps = {
|
|
|
46
51
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
47
52
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
48
53
|
*/
|
|
49
|
-
layout?:
|
|
54
|
+
layout?: CircleLayerSpecification['layout'] | FillLayerSpecification['layout'] | LineLayerSpecification['layout'];
|
|
50
55
|
/**
|
|
51
56
|
* Javascript object that is spread into the addLayer commands first parameter.
|
|
52
57
|
*/
|
|
53
|
-
options?:
|
|
58
|
+
options?: CircleLayerSpecification | FillLayerSpecification | LineLayerSpecification;
|
|
54
59
|
/**
|
|
55
60
|
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
56
61
|
*/
|
|
57
|
-
defaultPaintOverrides?:
|
|
62
|
+
defaultPaintOverrides?: { circle?: CircleLayerSpecification['paint'], fill?: FillLayerSpecification['paint'], line?: LineLayerSpecification['paint'] };
|
|
58
63
|
/**
|
|
59
64
|
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
60
65
|
*/
|
|
61
|
-
onHover?:
|
|
66
|
+
onHover?: MapLayerMouseEvent;
|
|
62
67
|
/**
|
|
63
68
|
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
64
69
|
*/
|
|
65
|
-
onClick?:
|
|
70
|
+
onClick?: MapLayerMouseEvent;
|
|
66
71
|
/**
|
|
67
72
|
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
68
73
|
* left/unhovered.
|
|
69
74
|
*/
|
|
70
|
-
onLeave?:
|
|
75
|
+
onLeave?: MapLayerMouseEvent;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
/**
|
|
@@ -91,7 +96,7 @@ const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => {
|
|
|
91
96
|
),
|
|
92
97
|
layout: props.layout || {},
|
|
93
98
|
...props.options,
|
|
94
|
-
type: layerType,
|
|
99
|
+
type: layerType as LayerSpecification['type'],
|
|
95
100
|
},
|
|
96
101
|
insertBeforeLayer: props.insertBeforeLayer,
|
|
97
102
|
onHover: props.onHover,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
2
|
+
import { LayerSpecification } from "maplibre-gl";
|
|
2
3
|
|
|
3
4
|
const mapGeometryTypesToLayerTypes = {
|
|
4
5
|
Position: "circle",
|
|
@@ -13,7 +14,7 @@ const mapGeometryTypesToLayerTypes = {
|
|
|
13
14
|
|
|
14
15
|
const getDefaulLayerTypeByGeometry: Function = (
|
|
15
16
|
geojson: Feature | FeatureCollection
|
|
16
|
-
):
|
|
17
|
+
): LayerSpecification['type'] => {
|
|
17
18
|
if (geojson?.type === "Feature") {
|
|
18
19
|
return mapGeometryTypesToLayerTypes?.[geojson?.geometry?.type]
|
|
19
20
|
? mapGeometryTypesToLayerTypes[geojson.geometry.type]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import MlMeasureTool from "./MlMeasureTool";
|
|
4
4
|
|
|
@@ -7,61 +7,90 @@ import StraightenOutlinedIcon from "@mui/icons-material/StraightenOutlined";
|
|
|
7
7
|
import SquareFootOutlinedIcon from "@mui/icons-material/SquareFootOutlined";
|
|
8
8
|
import Grid from "@mui/material/Grid";
|
|
9
9
|
import Box from "@mui/material/Box";
|
|
10
|
+
import { MenuItem, Select } from "@mui/material";
|
|
10
11
|
|
|
11
12
|
const storyoptions = {
|
|
12
13
|
title: "MapComponents/MlMeasureTool",
|
|
13
14
|
component: MlMeasureTool,
|
|
14
|
-
argTypes: {
|
|
15
|
-
},
|
|
15
|
+
argTypes: {},
|
|
16
16
|
decorators: mapContextDecorator,
|
|
17
17
|
};
|
|
18
18
|
export default storyoptions;
|
|
19
19
|
|
|
20
|
-
const Template = (args) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
textAlign: "left",
|
|
26
|
-
alignItems: "center",
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
<SquareFootOutlinedIcon />
|
|
20
|
+
const Template = (args) => {
|
|
21
|
+
const [unit, setUnit] = useState("kilometers");
|
|
22
|
+
const handleChange = (event) => {
|
|
23
|
+
setUnit(event.target.value);
|
|
24
|
+
};
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
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>
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
48
|
+
<Box m={2} style={{ textAlign: "left" }}>
|
|
49
|
+
Area: <MlMeasureTool measureType={"polygon"} unit={unit} />
|
|
50
|
+
</Box>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
39
54
|
|
|
40
|
-
const LineTemplate = (args) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
textAlign: "left",
|
|
46
|
-
alignItems: "center",
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
<StraightenOutlinedIcon />
|
|
55
|
+
const LineTemplate = (args) => {
|
|
56
|
+
const [unit, setUnit] = useState("kilometers");
|
|
57
|
+
const handleChange = (event) => {
|
|
58
|
+
setUnit(event.target.value);
|
|
59
|
+
};
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
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>
|
|
53
82
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
83
|
+
<Box m={2} style={{ textAlign: "left" }}>
|
|
84
|
+
Length: <MlMeasureTool measureType={"line"} unit={unit} />
|
|
85
|
+
</Box>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
59
89
|
|
|
60
|
-
export const MeasureLine = LineTemplate.bind(
|
|
90
|
+
export const MeasureLine = LineTemplate.bind({});
|
|
61
91
|
MeasureLine.parameters = {};
|
|
62
92
|
MeasureLine.args = {};
|
|
63
93
|
|
|
64
94
|
export const MeasurePolygon = Template.bind({});
|
|
65
95
|
MeasurePolygon.parameters = {};
|
|
66
96
|
MeasurePolygon.args = {};
|
|
67
|
-
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import MlFeatureEditor from "../MlFeatureEditor/MlFeatureEditor";
|
|
3
3
|
import * as turf from "@turf/turf";
|
|
4
4
|
|
|
@@ -6,28 +6,55 @@ interface MlMeasureToolProps {
|
|
|
6
6
|
/**
|
|
7
7
|
* String that specify if the Tool measures an area ("polygon") or length ("line")
|
|
8
8
|
*/
|
|
9
|
-
measureType
|
|
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';
|
|
10
25
|
}
|
|
11
26
|
|
|
12
27
|
const MlMeasureTool = (props: MlMeasureToolProps) => {
|
|
13
|
-
const [length, setLength] = useState(0)
|
|
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]);
|
|
14
40
|
|
|
15
41
|
return (
|
|
16
42
|
<>
|
|
17
43
|
<MlFeatureEditor
|
|
18
|
-
onChange={(features) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}}}
|
|
23
|
-
mode = {props.measureType === "polygon" ? "custom_polygon" : "draw_line_string"}
|
|
44
|
+
onChange={(features:any) => {
|
|
45
|
+
setCurrentFeatures(features);
|
|
46
|
+
}}
|
|
47
|
+
mode={props.measureType === "polygon" ? "custom_polygon" : "draw_line_string"}
|
|
24
48
|
/>
|
|
25
|
-
{
|
|
26
|
-
|
|
49
|
+
{length.toFixed(2)} {getUnitLabel(props.unit)}
|
|
50
|
+
{props.measureType === "polygon" ? "²" : ""}
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
27
53
|
};
|
|
28
54
|
|
|
29
55
|
MlMeasureTool.defaultProps = {
|
|
30
56
|
mapId: undefined,
|
|
31
57
|
measureType: "line",
|
|
58
|
+
unit: "kilometers",
|
|
32
59
|
};
|
|
33
60
|
export default MlMeasureTool;
|