@mapcomponents/react-maplibre 0.1.34 → 0.1.37
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/.babelrc +3 -0
- package/.github/workflows/storybook.yml +1 -1
- package/.storybook/.babelrc +26 -0
- package/.storybook/main.js +15 -1
- package/.storybook/mapcomponents_logo.png +0 -0
- package/CHANGELOG.md +16 -1
- package/config/env.js +106 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +75 -0
- package/config/pnpTs.js +35 -0
- package/config/webpack.config.js +757 -0
- package/config/webpackDevServer.config.js +130 -0
- package/coverage/clover.xml +822 -900
- package/coverage/coverage-final.json +23 -24
- package/coverage/lcov-report/index.html +135 -150
- package/coverage/lcov-report/src/components/MapLibreMap/{MapLibreMap.js.html → MapLibreMap.tsx.html} +77 -68
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +6 -6
- package/coverage/lcov-report/src/components/MlCreatePdfButton/{MlCreatePdfButton.js.html → MlCreatePdfButton.tsx.html} +40 -43
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +10 -10
- package/coverage/lcov-report/src/components/MlFeatureEditor/{MlFeatureEditor.js.html → MlFeatureEditor.tsx.html} +145 -85
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +21 -21
- package/coverage/lcov-report/src/components/{MlImageMarkerLayer/MlImageMarkerLayer.js.html → MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html} +141 -111
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +20 -20
- package/coverage/lcov-report/src/components/MlFollowGps/{MlFollowGps.js.html → MlFollowGps.tsx.html} +177 -138
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
- package/coverage/lcov-report/src/components/MlGPXViewer/{MlGPXViewer.js.html → MlGPXViewer.tsx.html} +134 -80
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +16 -16
- package/coverage/lcov-report/src/components/{MlLayer/MlLayer.js.html → MlGeoJsonLayer/MlGeoJsonLayer.tsx.html} +151 -154
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +19 -19
- package/coverage/lcov-report/src/components/{MlFillExtrusionLayer/MlFillExtrusionLayer.js.html → MlImageMarkerLayer/MlImageMarkerLayer.tsx.html} +151 -223
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +16 -16
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +229 -0
- package/coverage/lcov-report/src/components/MlLayer/index.html +21 -21
- package/coverage/lcov-report/src/components/MlLayerMagnify/{MlLayerMagnify.js.html → MlLayerMagnify.tsx.html} +134 -77
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +20 -20
- package/coverage/lcov-report/src/components/MlLayerSwipe/{MlLayerSwipe.js.html → MlLayerSwipe.tsx.html} +83 -41
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +2 -2
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +3 -15
- 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.js.html → MlMarker.tsx.html} +89 -137
- package/coverage/lcov-report/src/components/MlMarker/index.html +10 -10
- package/coverage/lcov-report/src/components/MlNavigationCompass/{MlNavigationCompass.js.html → MlNavigationCompass.tsx.html} +76 -25
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +17 -17
- package/coverage/lcov-report/src/components/MlNavigationTools/{MlNavigationTools.js.html → MlNavigationTools.tsx.html} +67 -52
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +10 -10
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.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 +3 -3
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +5 -5
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/{MlTransitionGeoJsonLayer.js.html → MlTransitionGeoJsonLayer.tsx.html} +127 -118
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +11 -11
- 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.js.html → MlVectorTileLayer.tsx.html} +59 -11
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +2 -2
- 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.js.html → MlWmsLayer.tsx.html} +56 -11
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +2 -2
- package/coverage/lcov-report/src/components/MlWmsLoader/{MlWmsLoader.js.html → MlWmsLoader.tsx.html} +102 -78
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +8 -8
- package/coverage/lcov-report/src/hooks/index.html +44 -29
- package/coverage/lcov-report/src/{components/MlGeoJsonLayer/MlGeoJsonLayer.js.html → hooks/useLayer.ts.html} +328 -184
- package/coverage/lcov-report/src/hooks/{useMap.js.html → useMap.ts.html} +140 -50
- package/coverage/lcov-report/src/hooks/{useMapState.js.html → useMapState.ts.html} +166 -61
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/index.html +15 -15
- package/coverage/lcov-report/src/{i18n.js.html → index.ts.html} +50 -32
- package/coverage/lcov.info +1540 -1669
- package/dist/index.esm.css +195 -0
- package/dist/index.esm.js +42894 -4862
- package/dist/index.esm.js.map +1 -1
- package/docs-build/0.d0c23b79.iframe.bundle.js +2 -0
- package/docs-build/0.d0c23b79.iframe.bundle.js.map +1 -0
- package/docs-build/0.fd1aa3ea21956d993519.manager.bundle.js +1 -0
- package/docs-build/1.34075652.iframe.bundle.js +10 -0
- package/docs-build/1.34075652.iframe.bundle.js.map +1 -0
- package/docs-build/16.ca488dae.iframe.bundle.js +2 -0
- package/docs-build/16.ca488dae.iframe.bundle.js.map +1 -0
- package/docs-build/17.e40eac7f.iframe.bundle.js +17 -0
- package/docs-build/17.e40eac7f.iframe.bundle.js.map +1 -0
- package/docs-build/18.62af0912.iframe.bundle.js +14 -0
- package/docs-build/18.62af0912.iframe.bundle.js.map +1 -0
- package/docs-build/19.0a217189.iframe.bundle.js +2 -0
- package/docs-build/19.0a217189.iframe.bundle.js.map +1 -0
- package/docs-build/2.f15ae19a.iframe.bundle.js +2 -0
- package/docs-build/2.f15ae19a.iframe.bundle.js.map +1 -0
- package/docs-build/20.4c43e27c.iframe.bundle.js +4 -0
- package/docs-build/20.4c43e27c.iframe.bundle.js.map +1 -0
- package/docs-build/21.19c21085.iframe.bundle.js +22 -0
- package/docs-build/21.19c21085.iframe.bundle.js.map +1 -0
- package/docs-build/3.5dd9e88b.iframe.bundle.js +2 -0
- package/docs-build/3.5dd9e88b.iframe.bundle.js.map +1 -0
- package/docs-build/4.f741dafe1833630ec8bf.manager.bundle.js +2 -0
- package/docs-build/4.f741dafe1833630ec8bf.manager.bundle.js.LICENSE.txt +8 -0
- package/docs-build/5.d4de191e7daeefb036ca.manager.bundle.js +1 -0
- package/docs-build/6.2b178c5444648ee5c0fa.manager.bundle.js +2 -0
- package/docs-build/6.2b178c5444648ee5c0fa.manager.bundle.js.LICENSE.txt +12 -0
- package/docs-build/7.7c16aea8ec7ea6e91994.manager.bundle.js +1 -0
- package/docs-build/8.52fa838fdf937b29676a.manager.bundle.js +1 -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 +716 -0
- package/docs-build/{.gitkeep → catalogue/.gitkeep} +0 -0
- package/docs-build/catalogue/mc_meta.json +1 -0
- package/docs-build/favicon.ico +0 -0
- package/docs-build/iframe.html +348 -0
- package/docs-build/index.html +59 -0
- package/docs-build/logo.png +0 -0
- package/docs-build/main.8a7ec710ea1c16b5e13f.manager.bundle.js +1 -0
- package/docs-build/main~24120820.ba6665a8.iframe.bundle.js +2 -0
- package/docs-build/main~24120820.ba6665a8.iframe.bundle.js.map +1 -0
- package/docs-build/manifest.json +25 -0
- package/docs-build/robots.txt +3 -0
- package/docs-build/runtime~main.67aa1de2d72f40a81164.manager.bundle.js +1 -0
- 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/stories.json +331 -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.351900838c49e9200954.manager.bundle.js +2 -0
- package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js.LICENSE.txt +101 -0
- package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js +8 -0
- package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js +2 -0
- package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js +2 -0
- package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js +8 -0
- package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~73914085.227c6747.iframe.bundle.js +293 -0
- package/docs-build/vendors~main~73914085.227c6747.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js +7 -0
- package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js +21 -0
- package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~b8f44717.7a612c34.iframe.bundle.js +89 -0
- package/docs-build/vendors~main~b8f44717.7a612c34.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js +68 -0
- package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js +2 -0
- package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~dab50aa4.b0d58038.iframe.bundle.js +107 -0
- package/docs-build/vendors~main~dab50aa4.b0d58038.iframe.bundle.js.map +1 -0
- package/package.json +131 -113
- package/public/favicon.ico +0 -0
- package/public/logo.png +0 -0
- package/rollup.config.js +26 -3
- package/scripts/start.js +166 -0
- package/scripts/test.js +53 -0
- package/src/components/MapLibreMap/MapLibreMap.stories.js +14 -5
- package/src/components/MapLibreMap/MapLibreMap.test.js +1 -1
- package/src/components/MapLibreMap/{MapLibreMap.js → MapLibreMap.tsx} +40 -37
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +3 -3
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +636 -0
- package/src/components/MlComponentTemplate/MlComponentTemplate.stories.js +0 -2
- package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +42 -0
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.stories.js +0 -5
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +51 -0
- package/src/components/MlCreatePdfButton/lib/{createPdf.js → createPdf.ts} +26 -23
- package/src/components/MlCreatePdfButton/lib/{nominatimMap.js → nominatimMap.ts} +3 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +139 -0
- package/src/components/MlFeatureEditor/custom-direct-select-mode.js +12 -8
- package/src/components/MlFeatureEditor/custom-polygon-mode.js +9 -5
- package/src/components/MlFeatureEditor/custom-select-mode.js +11 -7
- package/src/components/MlFeatureEditor/lib/LICENSE.md +18 -0
- package/src/components/MlFeatureEditor/lib/common_selectors.js +4 -0
- package/src/components/MlFeatureEditor/lib/constants.js +4 -0
- package/src/components/MlFeatureEditor/lib/constrain_feature_movement.js +4 -0
- package/src/components/MlFeatureEditor/lib/create_midpoint.js +4 -0
- package/src/components/MlFeatureEditor/lib/create_supplementary_points.js +4 -0
- package/src/components/MlFeatureEditor/lib/create_vertex.js +4 -0
- package/src/components/MlFeatureEditor/lib/double_click_zoom.js +4 -0
- package/src/components/MlFeatureEditor/lib/euclidean_distance.js +4 -0
- package/src/components/MlFeatureEditor/lib/features_at.js +4 -0
- package/src/components/MlFeatureEditor/lib/get_features_and_set_cursor.js +4 -0
- package/src/components/MlFeatureEditor/lib/is_click.js +4 -0
- package/src/components/MlFeatureEditor/lib/is_event_at_coordinates.js +4 -0
- package/src/components/MlFeatureEditor/lib/is_tap.js +4 -0
- package/src/components/MlFeatureEditor/lib/map_event_to_bounding_box.js +4 -0
- package/src/components/MlFeatureEditor/lib/mode_handler.js +4 -0
- package/src/components/MlFeatureEditor/lib/mouse_event_point.js +4 -0
- package/src/components/MlFeatureEditor/lib/move_features.js +4 -0
- package/src/components/MlFeatureEditor/lib/sort_features.js +4 -0
- package/src/components/MlFeatureEditor/lib/string_set.js +4 -0
- package/src/components/MlFeatureEditor/lib/string_sets_are_equal.js +4 -0
- package/src/components/MlFeatureEditor/lib/theme.js +4 -0
- package/src/components/MlFeatureEditor/lib/to_dense_array.js +4 -0
- package/src/components/MlFeatureEditor/lib/utils.js +4 -0
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.js +6 -11
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx +85 -0
- package/src/components/MlFollowGps/MlFollowGps.stories.js +0 -2
- package/src/components/MlFollowGps/{MlFollowGps.js → MlFollowGps.tsx} +99 -86
- package/src/components/MlGPXViewer/{MlGPXViewer.js → MlGPXViewer.tsx} +68 -50
- package/src/components/MlGPXViewer/util/GeoJsonContext.ts +13 -0
- package/src/components/MlGPXViewer/util/{GeoJsonProvider.js → GeoJsonProvider.tsx} +3 -7
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +8 -3
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +106 -0
- package/src/components/MlGeoJsonLayer/util/{getDefaultLayerTypeByGeometry.js → getDefaultLayerTypeByGeometry.ts} +6 -1
- package/src/components/MlGeoJsonLayer/util/{getDefaultPaintPropsByType.js → getDefaultPaintPropsByType.ts} +1 -1
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +1 -4
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +129 -0
- package/src/components/MlLayer/MlLayer.stories.js +0 -2
- package/src/components/MlLayer/MlLayer.tsx +48 -0
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +3 -3
- package/src/components/MlLayerMagnify/{MlLayerMagnify.js → MlLayerMagnify.tsx} +62 -43
- package/src/components/MlLayerSwipe/MlLayerSwipe.stories.js +0 -2
- package/src/components/MlLayerSwipe/{MlLayerSwipe.js → MlLayerSwipe.tsx} +38 -24
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +0 -4
- package/src/components/MlMarker/MlMarker.tsx +140 -0
- package/src/components/MlNavigationCompass/{MlNavigationCompass.js → MlNavigationCompass.tsx} +27 -10
- package/src/components/MlNavigationTools/{MlNavigationTools.js → MlNavigationTools.tsx} +37 -32
- package/src/components/MlTransitionGeoJsonLayer/{MlTransitionGeoJsonLayer.js → MlTransitionGeoJsonLayer.tsx} +76 -73
- package/src/components/MlVectorTileLayer/{MlVectorTileLayer.js → MlVectorTileLayer.tsx} +23 -7
- package/src/components/MlWmsLayer/{MlWmsLayer.js → MlWmsLayer.tsx} +22 -7
- package/src/components/MlWmsLoader/{MlWmsLoader.js → MlWmsLoader.tsx} +55 -47
- package/src/custom.d.tsx +26 -0
- package/src/hooks/useLayer.ts +221 -0
- package/src/hooks/{useMap.js → useMap.ts} +48 -17
- package/src/hooks/{useMapState.js → useMapState.ts} +42 -7
- package/src/{index.js → index.ts} +15 -8
- package/tsconfig.json +18 -24
- package/.env +0 -1
- package/.storybook/main.bck.js +0 -56
- package/babel.config.json +0 -4
- package/coverage/lcov-report/src/translations/english.js.html +0 -94
- package/coverage/lcov-report/src/translations/german.js.html +0 -94
- package/coverage/lcov-report/src/translations/index.html +0 -131
- package/jest.config.json +0 -16
- package/jsdoc.json +0 -21
- package/public/assets/3D/posttower.gltf +0 -103
- package/public/assets/3D/posttower_simple.gltf +0 -103
- package/public/assets/3D/posttower_wh.gltf.glb +0 -0
- package/public/bee.png +0 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +0 -528
- package/src/components/MlComponentTemplate/MlComponentTemplate.js +0 -39
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.js +0 -52
- package/src/components/MlFeatureEditor/MlFeatureEditor.js +0 -119
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js +0 -153
- package/src/components/MlGPXViewer/util/GeoJsonContext.js +0 -6
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +0 -173
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +0 -75
- package/src/components/MlLayer/MlLayer.js +0 -107
- package/src/components/MlLayerMagnify/utils/compareMagnify.js +0 -173
- package/src/components/MlLayerSwipe/utils/swipeCompare.js +0 -220
- package/src/components/MlMarker/MlMarker.js +0 -156
- package/src/components/index.js +0 -6
- package/src/i18n.js +0 -28
- package/src/react-app-env.d.ts +0 -1
- package/src/stories/IntroductionCore.stories.mdx +0 -3
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/stories/components/ComponentTeaser.js +0 -64
- package/src/translations/english.js +0 -4
- package/src/translations/german.js +0 -4
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useContext } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { MapContext } from "@mapcomponents/react-core";
|
|
4
|
-
|
|
5
|
-
import createPdf from "./lib/createPdf.js";
|
|
6
|
-
|
|
7
|
-
import PrinterIcon from "@mui/icons-material/Print";
|
|
8
|
-
import Button from "@mui/material/Button";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Renders a button that will create a PDF version of the current map view (dimensions adjusted to fit Din A4 Paper).
|
|
12
|
-
*
|
|
13
|
-
* @component
|
|
14
|
-
*/
|
|
15
|
-
const MlCreatePdfButton = (props) => {
|
|
16
|
-
const mapContext = useContext(MapContext);
|
|
17
|
-
const initializedRef = useRef(false);
|
|
18
|
-
const mapRef = useRef(undefined);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
22
|
-
initializedRef.current = true;
|
|
23
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
24
|
-
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<>
|
|
28
|
-
<Button
|
|
29
|
-
color="primary"
|
|
30
|
-
variant="contained"
|
|
31
|
-
onClick={() => {
|
|
32
|
-
createPdf(mapRef.current, null, () => {});
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
<PrinterIcon />
|
|
36
|
-
</Button>
|
|
37
|
-
</>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
MlCreatePdfButton.defaultProps = {
|
|
42
|
-
mapId: undefined,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
MlCreatePdfButton.propTypes = {
|
|
46
|
-
/**
|
|
47
|
-
* Id of the target MapLibre instance in mapContext
|
|
48
|
-
*/
|
|
49
|
-
mapId: PropTypes.string,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default MlCreatePdfButton;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useContext, useRef } from "react";
|
|
2
|
-
import "./MlFeatureEditor.css";
|
|
3
|
-
|
|
4
|
-
import "@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css";
|
|
5
|
-
import MapboxDraw from "@mapbox/mapbox-gl-draw";
|
|
6
|
-
import CustomPolygonMode from "./custom-polygon-mode";
|
|
7
|
-
import CustomSelectMode from "./custom-select-mode";
|
|
8
|
-
import CustomDirectSelectMode from "./custom-direct-select-mode";
|
|
9
|
-
import { v4 as uuidv4 } from "uuid";
|
|
10
|
-
|
|
11
|
-
import { MapContext } from "@mapcomponents/react-core";
|
|
12
|
-
|
|
13
|
-
function MlFeatureEditor(props) {
|
|
14
|
-
const mapRef = useRef(null);
|
|
15
|
-
const draw = useRef(null);
|
|
16
|
-
const mapContext = useContext(MapContext);
|
|
17
|
-
const componentId = useRef(
|
|
18
|
-
(props.idPrefix ? props.idPrefix : "MlFeatureEditor-") + uuidv4()
|
|
19
|
-
);
|
|
20
|
-
const onChangeRef = useRef(props.onChange);
|
|
21
|
-
|
|
22
|
-
const [drawToolsInitialized, setDrawToolsInitialized] = useState(false);
|
|
23
|
-
const [drawToolsReady, setDrawToolsReady] = useState(false);
|
|
24
|
-
|
|
25
|
-
const [mouseUpTrigger, setMouseUpTrigger] = useState(false);
|
|
26
|
-
|
|
27
|
-
const modeChangeHandler = (e) => {
|
|
28
|
-
console.log("MlFeatureEditor mode change to " + e.mode);
|
|
29
|
-
//setDrawMode(e.mode);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const mouseUpHandler = () => {
|
|
33
|
-
setMouseUpTrigger(Math.random());
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
let _componentId = componentId.current;
|
|
38
|
-
return () => {
|
|
39
|
-
if (mapRef.current) {
|
|
40
|
-
mapRef.current.cleanup(_componentId);
|
|
41
|
-
//mapRef.current.removeControl(draw.current, "top-left");
|
|
42
|
-
mapRef.current = null;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (
|
|
49
|
-
mapContext.mapExists(props.mapId) &&
|
|
50
|
-
mapContext.getMap(props.mapId).style &&
|
|
51
|
-
!drawToolsInitialized
|
|
52
|
-
) {
|
|
53
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
54
|
-
setDrawToolsInitialized(true);
|
|
55
|
-
if (
|
|
56
|
-
mapRef.current &&
|
|
57
|
-
mapRef.current.style &&
|
|
58
|
-
mapRef.current.getSource("mapbox-gl-draw-cold") &&
|
|
59
|
-
draw.current &&
|
|
60
|
-
typeof draw.current.remove !== "undefined"
|
|
61
|
-
) {
|
|
62
|
-
// remove old Mapbox-gl-Draw from Mapbox instance when hot-reloading this component during development
|
|
63
|
-
draw.current.remove();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
draw.current = new MapboxDraw({
|
|
67
|
-
displayControlsDefault: false,
|
|
68
|
-
defaultMode: props.mode || "custom_select",
|
|
69
|
-
modes: Object.assign(
|
|
70
|
-
{
|
|
71
|
-
custom_polygon: CustomPolygonMode,
|
|
72
|
-
custom_select: CustomSelectMode,
|
|
73
|
-
custom_direct_select: CustomDirectSelectMode,
|
|
74
|
-
},
|
|
75
|
-
MapboxDraw.modes
|
|
76
|
-
),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
mapRef.current.on("draw.modechange", modeChangeHandler, componentId.current);
|
|
80
|
-
|
|
81
|
-
mapRef.current.addControl(draw.current, "top-left", componentId.current);
|
|
82
|
-
|
|
83
|
-
mapRef.current.on("mouseup", mouseUpHandler, componentId.current);
|
|
84
|
-
|
|
85
|
-
setDrawToolsReady(true);
|
|
86
|
-
}
|
|
87
|
-
}, [mapContext.map, mapContext, props, drawToolsInitialized]);
|
|
88
|
-
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (
|
|
91
|
-
draw.current &&
|
|
92
|
-
props.geojson &&
|
|
93
|
-
props.geojson.geometry &&
|
|
94
|
-
props.geojson.geometry.coordinates
|
|
95
|
-
) {
|
|
96
|
-
draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
|
|
97
|
-
}
|
|
98
|
-
}, [props.geojson, drawToolsReady]);
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (draw.current && mouseUpTrigger) {
|
|
102
|
-
// update drawnFeatures state object
|
|
103
|
-
let currentFeatureCollection = draw.current.getAll();
|
|
104
|
-
if (typeof onChangeRef.current === "function") {
|
|
105
|
-
onChangeRef.current(currentFeatureCollection.features);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [mouseUpTrigger]);
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (props.mode && draw.current) {
|
|
112
|
-
draw.current.changeMode(props.mode);
|
|
113
|
-
}
|
|
114
|
-
}, [props.mode]);
|
|
115
|
-
|
|
116
|
-
return <></>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default MlFeatureEditor;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect, useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { MapContext } from "@mapcomponents/react-core";
|
|
4
|
-
|
|
5
|
-
import { v4 as uuidv4 } from "uuid";
|
|
6
|
-
import Button from "@mui/material/Button";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Adds a fill extrusion layer to the MapLibre instance reference by props.mapId
|
|
10
|
-
*
|
|
11
|
-
* @Component
|
|
12
|
-
*/
|
|
13
|
-
const MlFillExtrusionLayer = (props) => {
|
|
14
|
-
const mapContext = useContext(MapContext);
|
|
15
|
-
const mapRef = useRef(null);
|
|
16
|
-
|
|
17
|
-
const [showLayer, setShowLayer] = useState(true);
|
|
18
|
-
const componentId = useRef(
|
|
19
|
-
(props.idPrefix ? props.idPrefix : "MlFillExtrusionLayer-") + uuidv4()
|
|
20
|
-
);
|
|
21
|
-
const initializedRef = useRef(false);
|
|
22
|
-
const layerId = useRef(props.layerId || "MlFillExtrusionLayer-" + uuidv4());
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
let _componentId = componentId.current;
|
|
26
|
-
|
|
27
|
-
return () => {
|
|
28
|
-
if (mapRef.current) {
|
|
29
|
-
mapRef.current.cleanup(_componentId);
|
|
30
|
-
mapRef.current = undefined;
|
|
31
|
-
}
|
|
32
|
-
initializedRef.current = false;
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
38
|
-
// the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
39
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
40
|
-
initializedRef.current = true;
|
|
41
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
42
|
-
|
|
43
|
-
let lastLabelLayerId = undefined;
|
|
44
|
-
if (mapContext.map.getLayer("waterway-name")) {
|
|
45
|
-
lastLabelLayerId = "waterway-name";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (mapContext.map.getLayer("poi_label")) {
|
|
49
|
-
lastLabelLayerId = "poi_label";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
mapContext.map.addLayer(
|
|
53
|
-
{
|
|
54
|
-
id: layerId.current,
|
|
55
|
-
type: "fill-extrusion",
|
|
56
|
-
source: props.sourceId || "openmaptiles",
|
|
57
|
-
"source-layer": props.sourceLayer || "building",
|
|
58
|
-
minzoom: props.minZoom || 14,
|
|
59
|
-
paint: {
|
|
60
|
-
...props.paint,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
props.insertBeforeLayer || lastLabelLayerId,
|
|
64
|
-
componentId.current
|
|
65
|
-
);
|
|
66
|
-
}, [
|
|
67
|
-
mapContext,
|
|
68
|
-
props.insertBeforeLayer,
|
|
69
|
-
props.mapId,
|
|
70
|
-
props.minZoom,
|
|
71
|
-
props.paint,
|
|
72
|
-
props.sourceId,
|
|
73
|
-
props.sourceLayer,
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (!initializedRef.current) return;
|
|
78
|
-
|
|
79
|
-
// toggle layer visibility by changing the layout object's visibility property
|
|
80
|
-
mapRef.current.setLayoutProperty(layerId.current, "visibility", showLayer ? "visible" : "none");
|
|
81
|
-
}, [showLayer, mapContext]);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<Button
|
|
85
|
-
color="primary"
|
|
86
|
-
variant={showLayer ? "contained" : "outlined"}
|
|
87
|
-
onClick={() => setShowLayer(!showLayer)}
|
|
88
|
-
>
|
|
89
|
-
Composite
|
|
90
|
-
</Button>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
MlFillExtrusionLayer.defaultProps = {
|
|
95
|
-
mapId: undefined,
|
|
96
|
-
paint: {
|
|
97
|
-
"fill-extrusion-color": "hsl(196, 61%, 83%)",
|
|
98
|
-
"fill-extrusion-height": {
|
|
99
|
-
property: "render_height",
|
|
100
|
-
type: "identity",
|
|
101
|
-
},
|
|
102
|
-
"fill-extrusion-base": {
|
|
103
|
-
property: "render_min_height",
|
|
104
|
-
type: "identity",
|
|
105
|
-
},
|
|
106
|
-
"fill-extrusion-opacity": 1,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
MlFillExtrusionLayer.propTypes = {
|
|
111
|
-
/**
|
|
112
|
-
* Id of the target MapLibre instance in mapContext
|
|
113
|
-
*/
|
|
114
|
-
mapId: PropTypes.string,
|
|
115
|
-
/**
|
|
116
|
-
* Id of the layer that will be added by this component
|
|
117
|
-
*/
|
|
118
|
-
layerId: PropTypes.string,
|
|
119
|
-
/**
|
|
120
|
-
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
121
|
-
*/
|
|
122
|
-
idPrefix: PropTypes.string,
|
|
123
|
-
/**
|
|
124
|
-
* Paint properties of the config object that is passed to the MapLibreGl.addLayer call. All
|
|
125
|
-
* available properties are documented in the MapLibreGl documentation
|
|
126
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill-extrusion
|
|
127
|
-
*/
|
|
128
|
-
paint: PropTypes.object,
|
|
129
|
-
/**
|
|
130
|
-
* Source id of a vector tile source containing the geometries to use for this fill-extrusion
|
|
131
|
-
* layer.
|
|
132
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
|
|
133
|
-
*/
|
|
134
|
-
sourceId: PropTypes.string,
|
|
135
|
-
/**
|
|
136
|
-
* Layer id from a vector tile source containing the geometries to use for this fill-extrusion
|
|
137
|
-
* layer.
|
|
138
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
|
|
139
|
-
*/
|
|
140
|
-
sourceLayer: PropTypes.string,
|
|
141
|
-
/**
|
|
142
|
-
* This layer will be hidde for zoom levels lower than defined on this property
|
|
143
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#minzoom
|
|
144
|
-
*/
|
|
145
|
-
minZoom: PropTypes.number,
|
|
146
|
-
/**
|
|
147
|
-
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
148
|
-
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
149
|
-
*/
|
|
150
|
-
insertBeforeLayer: PropTypes.string,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default MlFillExtrusionLayer;
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useCallback } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
|
|
4
|
-
import useMap from "../../hooks/useMap";
|
|
5
|
-
|
|
6
|
-
import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
7
|
-
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
8
|
-
|
|
9
|
-
const legalLayerTypes = ["circle", "fill", "line"];
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
13
|
-
*
|
|
14
|
-
* @component
|
|
15
|
-
*/
|
|
16
|
-
const MlGeoJsonLayer = (props) => {
|
|
17
|
-
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
18
|
-
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
19
|
-
const initializedRef = useRef(false);
|
|
20
|
-
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
21
|
-
const layerTypeRef = useRef(undefined);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (!mapHook.map || !initializedRef.current) return;
|
|
25
|
-
|
|
26
|
-
for (var key in props.layout) {
|
|
27
|
-
mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);
|
|
28
|
-
}
|
|
29
|
-
}, [props.layout, mapHook.map, props.mapId]);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (!mapHook.map || !initializedRef.current) return;
|
|
33
|
-
|
|
34
|
-
let _paint =
|
|
35
|
-
props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides);
|
|
36
|
-
|
|
37
|
-
for (var key in _paint) {
|
|
38
|
-
mapHook.map.setPaintProperty(layerId.current, key, _paint[key]);
|
|
39
|
-
}
|
|
40
|
-
}, [props.paint, mapHook.map, props.mapId, props.defaultPaintOverrides]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!mapHook?.map?.getSource(layerId.current) || !initializedRef.current) return;
|
|
44
|
-
|
|
45
|
-
mapHook.map.getSource(layerId.current).setData(props.geojson);
|
|
46
|
-
}, [props.geojson, mapHook.map, props.type]);
|
|
47
|
-
|
|
48
|
-
const createLayer = useCallback(() => {
|
|
49
|
-
let geojson = props.geojson;
|
|
50
|
-
|
|
51
|
-
layerTypeRef.current = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
52
|
-
|
|
53
|
-
mapHook.map.addLayer(
|
|
54
|
-
{
|
|
55
|
-
id: layerId.current,
|
|
56
|
-
source: {
|
|
57
|
-
type: "geojson",
|
|
58
|
-
data: geojson,
|
|
59
|
-
},
|
|
60
|
-
type: layerTypeRef.current,
|
|
61
|
-
paint:
|
|
62
|
-
props.paint ||
|
|
63
|
-
getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
64
|
-
layout: props.layout || {},
|
|
65
|
-
...props.options,
|
|
66
|
-
},
|
|
67
|
-
props.insertBeforeLayer,
|
|
68
|
-
mapHook.componentId
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (typeof props.onHover !== "undefined") {
|
|
72
|
-
mapHook.map.on("mousemove", layerId.current, props.onHover, mapHook.componentId);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (typeof props.onClick !== "undefined") {
|
|
76
|
-
mapHook.map.on("click", layerId.current, props.onClick, mapHook.componentId);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (typeof props.onLeave !== "undefined") {
|
|
80
|
-
mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
|
|
81
|
-
}
|
|
82
|
-
}, [mapHook, props]);
|
|
83
|
-
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
if (!mapHook.map || !props.geojson) return;
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
initializedRef.current &&
|
|
89
|
-
legalLayerTypes.indexOf(props.type) !== -1 &&
|
|
90
|
-
layerTypeRef.current &&
|
|
91
|
-
props.type !== layerTypeRef.current
|
|
92
|
-
) {
|
|
93
|
-
// remove (cleanup) & reinitialize the layer if type has changed
|
|
94
|
-
mapHook.map.cleanup(mapHook.componentId);
|
|
95
|
-
} else if (
|
|
96
|
-
initializedRef.current &&
|
|
97
|
-
(legalLayerTypes.indexOf(props.type) === -1 ||
|
|
98
|
-
(legalLayerTypes.indexOf(props.type) !== -1 && props.type === layerTypeRef.current))
|
|
99
|
-
) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
initializedRef.current = true;
|
|
104
|
-
|
|
105
|
-
createLayer();
|
|
106
|
-
}, [mapHook, createLayer, props]);
|
|
107
|
-
|
|
108
|
-
return <></>;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
MlGeoJsonLayer.propTypes = {
|
|
112
|
-
/**
|
|
113
|
-
* Id of the target MapLibre instance in mapContext
|
|
114
|
-
*/
|
|
115
|
-
mapId: PropTypes.string,
|
|
116
|
-
/**
|
|
117
|
-
* Type of the layer that will be added to the MapLibre instance.
|
|
118
|
-
* Possible values: "line", "circle", "fill"
|
|
119
|
-
*/
|
|
120
|
-
type: PropTypes.string,
|
|
121
|
-
/**
|
|
122
|
-
* Layout property object, that is passed to the addLayer call.
|
|
123
|
-
* Possible props depend on the layer type.
|
|
124
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
125
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
126
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
127
|
-
*/
|
|
128
|
-
layout: PropTypes.object,
|
|
129
|
-
/**
|
|
130
|
-
* Paint property object, that is passed to the addLayer call.
|
|
131
|
-
* Possible props depend on the layer type.
|
|
132
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
133
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
134
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
135
|
-
*/
|
|
136
|
-
paint: PropTypes.object,
|
|
137
|
-
/**
|
|
138
|
-
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
139
|
-
*/
|
|
140
|
-
defaultPaintOverrides: PropTypes.object,
|
|
141
|
-
/**
|
|
142
|
-
* Javascript object that is spread into the addLayer commands first parameter.
|
|
143
|
-
*/
|
|
144
|
-
options: PropTypes.object,
|
|
145
|
-
/**
|
|
146
|
-
* GeoJSON data that is supposed to be rendered by this component.
|
|
147
|
-
*/
|
|
148
|
-
geojson: PropTypes.object,
|
|
149
|
-
/**
|
|
150
|
-
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
151
|
-
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
152
|
-
*/
|
|
153
|
-
insertBeforeLayer: PropTypes.string,
|
|
154
|
-
/**
|
|
155
|
-
* Id of the new layer and source that are added to the MapLibre instance
|
|
156
|
-
*/
|
|
157
|
-
layerId: PropTypes.string,
|
|
158
|
-
/**
|
|
159
|
-
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
160
|
-
*/
|
|
161
|
-
onClick: PropTypes.func,
|
|
162
|
-
/**
|
|
163
|
-
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
164
|
-
*/
|
|
165
|
-
onHover: PropTypes.func,
|
|
166
|
-
/**
|
|
167
|
-
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
168
|
-
* left/unhovered.
|
|
169
|
-
*/
|
|
170
|
-
onLeave: PropTypes.func,
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export default MlGeoJsonLayer;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useCallback, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
import useMap from "../../hooks/useMap";
|
|
4
|
-
|
|
5
|
-
const MlImageMarkerLayer = (props) => {
|
|
6
|
-
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
7
|
-
|
|
8
|
-
const layerInitializedRef = useRef(false);
|
|
9
|
-
const imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
10
|
-
const layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (
|
|
14
|
-
!mapHook.mapIsReady ||
|
|
15
|
-
(mapHook.map && !mapHook.map.getLayer(layerId.current)) ||
|
|
16
|
-
!props.options
|
|
17
|
-
)
|
|
18
|
-
return;
|
|
19
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
20
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
21
|
-
var key;
|
|
22
|
-
|
|
23
|
-
if (props.options.layout) {
|
|
24
|
-
for (key in props.options.layout) {
|
|
25
|
-
mapHook.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (props.options.paint) {
|
|
29
|
-
for (key in props.options.paint) {
|
|
30
|
-
mapHook.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, [props.options, layerId.current, props.mapId]);
|
|
34
|
-
|
|
35
|
-
const addLayer = useCallback(() => {
|
|
36
|
-
let tmpOptions = {
|
|
37
|
-
id: layerId.current,
|
|
38
|
-
layout: {},
|
|
39
|
-
...props.options,
|
|
40
|
-
};
|
|
41
|
-
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
42
|
-
mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
|
|
43
|
-
}, [props, mapHook.mapIsReady, mapHook.map]);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
|
|
47
|
-
|
|
48
|
-
layerInitializedRef.current = true;
|
|
49
|
-
|
|
50
|
-
if (props.imgSrc) {
|
|
51
|
-
mapHook.map.loadImage(props.imgSrc, function (error, image) {
|
|
52
|
-
if (error) throw error;
|
|
53
|
-
mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
addLayer();
|
|
58
|
-
}, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (
|
|
62
|
-
!mapHook.mapIsReady ||
|
|
63
|
-
(mapHook.map && !mapHook.map.getLayer(layerId.current)) ||
|
|
64
|
-
!props.options
|
|
65
|
-
) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
mapHook.map.getSource(layerId.current).setData(props.options.source.data);
|
|
70
|
-
}, [props.options.source.data, props]);
|
|
71
|
-
|
|
72
|
-
return <></>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default MlImageMarkerLayer;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { v4 as uuidv4 } from "uuid";
|
|
4
|
-
import { MapContext } from "@mapcomponents/react-core";
|
|
5
|
-
import useMapState from "../../hooks/useMapState";
|
|
6
|
-
|
|
7
|
-
const MlLayer = (props) => {
|
|
8
|
-
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
9
|
-
const mapContext = useContext(MapContext);
|
|
10
|
-
|
|
11
|
-
const mapState = useMapState({
|
|
12
|
-
mapId: props.mapId,
|
|
13
|
-
watch: {
|
|
14
|
-
viewport: false,
|
|
15
|
-
layers: true,
|
|
16
|
-
sources: false,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
const layerInitializedRef = useRef(false);
|
|
20
|
-
const mapRef = useRef(null);
|
|
21
|
-
const componentId = useRef((props.layerId ? props.layerId : "MlLayer-") + uuidv4());
|
|
22
|
-
const layerId = useRef(props.layerId || componentId.current);
|
|
23
|
-
const layerPaintConfRef = useRef(undefined);
|
|
24
|
-
const layerLayoutConfRef = useRef(undefined);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
let _componentId = componentId.current;
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
if (mapRef.current) {
|
|
31
|
-
mapRef.current.cleanup(_componentId);
|
|
32
|
-
mapRef.current = null;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}, []);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (
|
|
39
|
-
!mapContext.mapExists(props.mapId) ||
|
|
40
|
-
!mapContext.getMap(props.mapId)?.getLayer?.(layerId) ||
|
|
41
|
-
!layerInitializedRef.current ||
|
|
42
|
-
!props.options
|
|
43
|
-
)
|
|
44
|
-
return;
|
|
45
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
46
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
47
|
-
var key;
|
|
48
|
-
|
|
49
|
-
let layoutString = JSON.stringify(props.options.layout);
|
|
50
|
-
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
51
|
-
for (key in props.options.layout) {
|
|
52
|
-
mapRef.current.setLayoutProperty(layerId, key, props.options.layout[key]);
|
|
53
|
-
}
|
|
54
|
-
layerLayoutConfRef.current = layoutString;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let paintString = JSON.stringify(props.options.paint);
|
|
58
|
-
if (props.options.paint && paintString === layerPaintConfRef.current) {
|
|
59
|
-
for (key in props.options.paint) {
|
|
60
|
-
mapRef.current.setPaintProperty(layerId, key, props.options.paint[key]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}, [props.options, layerId, mapContext, props]);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!mapContext.mapExists(props.mapId) || layerInitializedRef.current) return;
|
|
67
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
68
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
69
|
-
|
|
70
|
-
//check if insertBeforeLayer exists
|
|
71
|
-
if (props.insertBeforeLayer) {
|
|
72
|
-
let layerFound = false;
|
|
73
|
-
|
|
74
|
-
mapState?.layers?.forEach((layer) => {
|
|
75
|
-
if (layer.id === props.insertBeforeLayer) {
|
|
76
|
-
layerFound = true;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (!layerFound) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
85
|
-
if (mapRef.current) {
|
|
86
|
-
layerInitializedRef.current = true;
|
|
87
|
-
mapRef.current.addLayer(
|
|
88
|
-
{
|
|
89
|
-
id: layerId.current,
|
|
90
|
-
type: "background",
|
|
91
|
-
paint: {
|
|
92
|
-
"background-color": "rgba(0,0,0,0)",
|
|
93
|
-
},
|
|
94
|
-
...props.options,
|
|
95
|
-
},
|
|
96
|
-
props.insertBeforeLayer,
|
|
97
|
-
componentId.current
|
|
98
|
-
);
|
|
99
|
-
layerPaintConfRef.current = JSON.stringify(props.options?.paint);
|
|
100
|
-
layerLayoutConfRef.current = JSON.stringify(props.options?.layout);
|
|
101
|
-
}
|
|
102
|
-
}, [mapContext.mapIds, mapContext, props, mapState.layers]);
|
|
103
|
-
|
|
104
|
-
return <></>;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export default MlLayer;
|