@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
4
|
+
import useLayer from "../../hooks/useLayer";
|
|
5
|
+
|
|
6
|
+
interface MlFillExtrusionLayerProps {
|
|
7
|
+
/**
|
|
8
|
+
* Id of the target MapLibre instance in mapContext
|
|
9
|
+
*/
|
|
10
|
+
mapId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
13
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
14
|
+
*/
|
|
15
|
+
insertBeforeLayer?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Id of the layer that will be added by this component
|
|
18
|
+
*/
|
|
19
|
+
layerId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Paint properties of the config object that is passed to the MapLibreGl.addLayer call. All
|
|
22
|
+
* available properties are documented in the MapLibreGl documentation
|
|
23
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill-extrusion
|
|
24
|
+
*/
|
|
25
|
+
paint?: object;
|
|
26
|
+
/**
|
|
27
|
+
* Source id of a vector tile source containing the geometries to use for this fill-extrusion
|
|
28
|
+
* layer.
|
|
29
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
|
|
30
|
+
*/
|
|
31
|
+
sourceId?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Layer id from a vector tile source containing the geometries to use for this fill-extrusion
|
|
34
|
+
* layer.
|
|
35
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
|
|
36
|
+
*/
|
|
37
|
+
sourceLayer?: string;
|
|
38
|
+
/**
|
|
39
|
+
* This layer will be hidden for zoom levels lower than defined on this property
|
|
40
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#minzoom
|
|
41
|
+
*/
|
|
42
|
+
minZoom?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Adds a fill extrusion layer to the MapLibre instance reference by props.mapId
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
const MlFillExtrusionLayer = (props: MlFillExtrusionLayerProps) => {
|
|
50
|
+
useLayer({
|
|
51
|
+
mapId: props.mapId,
|
|
52
|
+
layerId: props.layerId || "MlFillExtrusionLayer-" + uuidv4(),
|
|
53
|
+
options: {
|
|
54
|
+
id: "",
|
|
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
|
+
insertBeforeFirstSymbolLayer: true,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return <></>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
MlFillExtrusionLayer.defaultProps = {
|
|
70
|
+
mapId: undefined,
|
|
71
|
+
paint: {
|
|
72
|
+
"fill-extrusion-color": "hsl(196, 61%, 83%)",
|
|
73
|
+
"fill-extrusion-height": {
|
|
74
|
+
property: "render_height",
|
|
75
|
+
type: "identity",
|
|
76
|
+
},
|
|
77
|
+
"fill-extrusion-base": {
|
|
78
|
+
property: "render_min_height",
|
|
79
|
+
type: "identity",
|
|
80
|
+
},
|
|
81
|
+
"fill-extrusion-opacity": 1,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default MlFillExtrusionLayer;
|
|
@@ -1,35 +1,85 @@
|
|
|
1
1
|
import React, { useEffect, useState, useCallback, useMemo } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import useMap from "../../hooks/useMap";
|
|
4
|
-
|
|
5
|
-
import Button from "@mui/material/Button";
|
|
6
|
-
import GpsFixedIcon from "@mui/icons-material/GpsFixed";
|
|
7
|
-
import { point, circle, lineArc } from "@turf/turf";
|
|
8
3
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
9
4
|
|
|
5
|
+
import { Button } from "@mui/material";
|
|
6
|
+
import GpsFixedIcon from "@mui/icons-material/GpsFixed";
|
|
7
|
+
|
|
8
|
+
import { point, circle, lineArc, Feature, Point } from "@turf/turf";
|
|
9
|
+
|
|
10
|
+
interface MlFollowGpsProps {
|
|
11
|
+
/**
|
|
12
|
+
* Id of the target MapLibre instance in mapContext
|
|
13
|
+
*/
|
|
14
|
+
mapId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
17
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
18
|
+
*/
|
|
19
|
+
insertBeforeLayer?: string;
|
|
20
|
+
/**
|
|
21
|
+
* By default a dot will be shown on the map at the user's location. Set to false to disable.
|
|
22
|
+
*/
|
|
23
|
+
showUserLocation?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* By default a cone will be shown on the map at the user's location to indicate the device's orientation.
|
|
26
|
+
* Set to false to disable.
|
|
27
|
+
*/
|
|
28
|
+
showOrientation?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* By default, if showUserLocation is true, a transparent circle will be drawn around the user location
|
|
31
|
+
* indicating the accuracy (95% confidence level) of the user's location. Set to false to disable.
|
|
32
|
+
*/
|
|
33
|
+
showAccuracyCircle?: boolean,
|
|
34
|
+
/**
|
|
35
|
+
* position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
|
|
36
|
+
* Use any available paint prop from layer type "fill".
|
|
37
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
38
|
+
*/
|
|
39
|
+
circlePaint?: any;
|
|
40
|
+
/**
|
|
41
|
+
* Active button font color
|
|
42
|
+
*/
|
|
43
|
+
onColor?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Inactive button font color
|
|
46
|
+
*/
|
|
47
|
+
offColor?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
|
|
50
|
+
* Use any available paint prop from layer type "fill".
|
|
51
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
52
|
+
*/
|
|
53
|
+
accuracyPaint?: any;
|
|
54
|
+
/**
|
|
55
|
+
* CSS style object that is applied to the button component
|
|
56
|
+
*/
|
|
57
|
+
style?: any;
|
|
58
|
+
}
|
|
59
|
+
|
|
10
60
|
/**
|
|
11
61
|
* Adds a button that makes the map follow the users GPS position using
|
|
12
62
|
* navigator.geolocation.watchPosition if activated
|
|
13
63
|
*
|
|
14
|
-
* @param {object} props
|
|
15
|
-
* @param {string} props.mapId Id of the target MapLibre instance in mapContext
|
|
16
|
-
*
|
|
17
|
-
* @component
|
|
18
64
|
*/
|
|
19
|
-
const MlFollowGps = (props) => {
|
|
20
|
-
const mapHook = useMap({
|
|
65
|
+
const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
66
|
+
const mapHook = useMap({
|
|
67
|
+
mapId: props.mapId,
|
|
68
|
+
waitForLayer: props.insertBeforeLayer,
|
|
69
|
+
});
|
|
21
70
|
|
|
22
71
|
const [isFollowed, setIsFollowed] = useState(false);
|
|
23
|
-
const [userLocationGeoJson, setUserLocationGeoJson] =
|
|
72
|
+
const [userLocationGeoJson, setUserLocationGeoJson] =
|
|
73
|
+
useState<Feature<Point>>();
|
|
24
74
|
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
25
|
-
const [accuracyGeoJson, setAccuracyGeoJson] = useState();
|
|
75
|
+
const [accuracyGeoJson, setAccuracyGeoJson] = useState<Feature>();
|
|
26
76
|
const [deviceOrientation, setDeviceOrientation] = useState(0);
|
|
27
77
|
|
|
28
78
|
const getLocationSuccess = useCallback(
|
|
29
79
|
(pos) => {
|
|
30
80
|
if (!mapHook.map) return;
|
|
31
81
|
|
|
32
|
-
mapHook.map.flyTo({
|
|
82
|
+
mapHook.map.map.flyTo({
|
|
33
83
|
center: [pos.coords.longitude, pos.coords.latitude],
|
|
34
84
|
zoom: 18,
|
|
35
85
|
speed: 1,
|
|
@@ -43,52 +93,55 @@ const MlFollowGps = (props) => {
|
|
|
43
93
|
[mapHook.map, props]
|
|
44
94
|
);
|
|
45
95
|
|
|
46
|
-
const getLocationError = (
|
|
96
|
+
const getLocationError = () => {
|
|
47
97
|
console.log("Access of user location denied");
|
|
48
98
|
setLocationAccessDenied(true);
|
|
49
99
|
};
|
|
50
100
|
|
|
51
|
-
const orientationCone = useMemo(
|
|
52
|
-
()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
setDeviceOrientation(-event.alpha)
|
|
70
|
-
}
|
|
101
|
+
const orientationCone = useMemo(() => {
|
|
102
|
+
if (!userLocationGeoJson) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
let radius = 0.02;
|
|
106
|
+
let bearing1 = deviceOrientation - 15;
|
|
107
|
+
let bearing2 = deviceOrientation + 15;
|
|
108
|
+
const options = { steps: 65 };
|
|
109
|
+
let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
|
|
110
|
+
let copy = arc;
|
|
111
|
+
copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
|
|
112
|
+
copy.geometry.coordinates.slice(0, 0);
|
|
113
|
+
return copy;
|
|
114
|
+
}, [deviceOrientation, userLocationGeoJson]);
|
|
115
|
+
|
|
116
|
+
const handleOrientation = (event: any) => {
|
|
117
|
+
setDeviceOrientation(-event.alpha);
|
|
118
|
+
};
|
|
71
119
|
|
|
72
120
|
useEffect(() => {
|
|
73
121
|
if (isFollowed) {
|
|
74
122
|
let _handleOrientation = handleOrientation;
|
|
75
|
-
window.addEventListener(
|
|
123
|
+
window.addEventListener("deviceorientation", _handleOrientation);
|
|
76
124
|
return () => {
|
|
77
|
-
window.removeEventListener(
|
|
78
|
-
}
|
|
125
|
+
window.removeEventListener("deviceorientation", _handleOrientation);
|
|
126
|
+
};
|
|
79
127
|
}
|
|
128
|
+
return;
|
|
80
129
|
}, [isFollowed]);
|
|
81
130
|
|
|
82
131
|
useEffect(() => {
|
|
83
132
|
if (!mapHook.map) return;
|
|
84
133
|
|
|
85
134
|
if (isFollowed) {
|
|
86
|
-
let _watchId = navigator.geolocation.watchPosition(
|
|
135
|
+
let _watchId = navigator.geolocation.watchPosition(
|
|
136
|
+
getLocationSuccess,
|
|
137
|
+
getLocationError
|
|
138
|
+
);
|
|
87
139
|
|
|
88
140
|
return () => {
|
|
89
141
|
navigator.geolocation.clearWatch(_watchId);
|
|
90
142
|
};
|
|
91
143
|
}
|
|
144
|
+
return;
|
|
92
145
|
}, [mapHook.map, isFollowed, getLocationSuccess]);
|
|
93
146
|
|
|
94
147
|
return (
|
|
@@ -135,14 +188,18 @@ const MlFollowGps = (props) => {
|
|
|
135
188
|
)}
|
|
136
189
|
|
|
137
190
|
<Button
|
|
138
|
-
sx={{
|
|
191
|
+
sx={{
|
|
192
|
+
zIndex: 1002,
|
|
193
|
+
color: isFollowed ? props.onColor : props.offColor,
|
|
194
|
+
...props.style,
|
|
195
|
+
}}
|
|
139
196
|
disabled={locationAccessDenied}
|
|
140
197
|
onClick={() => {
|
|
141
198
|
setIsFollowed(!isFollowed);
|
|
142
199
|
}}
|
|
143
200
|
>
|
|
144
201
|
{" "}
|
|
145
|
-
<GpsFixedIcon sx={{ fontSize: props.style
|
|
202
|
+
<GpsFixedIcon sx={{ ...(props.style?.fontSize?{fontSize: props.style?.fontSize}:{}) }} />{" "}
|
|
146
203
|
</Button>
|
|
147
204
|
</>
|
|
148
205
|
);
|
|
@@ -168,51 +225,7 @@ MlFollowGps.defaultProps = {
|
|
|
168
225
|
offColor: "#666",
|
|
169
226
|
showAccuracyCircle: true,
|
|
170
227
|
showUserLocation: true,
|
|
171
|
-
showOrientation: true
|
|
228
|
+
showOrientation: true,
|
|
172
229
|
};
|
|
173
230
|
|
|
174
|
-
MlFollowGps.propTypes = {
|
|
175
|
-
/**
|
|
176
|
-
* Id of the target MapLibre instance in mapContext
|
|
177
|
-
*/
|
|
178
|
-
mapId: PropTypes.string,
|
|
179
|
-
/**
|
|
180
|
-
* CSS style object that is applied to the button component
|
|
181
|
-
*/
|
|
182
|
-
style: PropTypes.object,
|
|
183
|
-
/**
|
|
184
|
-
* Active button font color
|
|
185
|
-
*/
|
|
186
|
-
onColor: PropTypes.string,
|
|
187
|
-
/**
|
|
188
|
-
* Inactive button font color
|
|
189
|
-
*/
|
|
190
|
-
offColor: PropTypes.string,
|
|
191
|
-
/**
|
|
192
|
-
* Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
|
|
193
|
-
* Use any available paint prop from layer type "fill".
|
|
194
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
195
|
-
*/
|
|
196
|
-
accuracyPaint: PropTypes.object,
|
|
197
|
-
/**
|
|
198
|
-
* position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
|
|
199
|
-
* Use any available paint prop from layer type "fill".
|
|
200
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
201
|
-
*/
|
|
202
|
-
circlePaint: PropTypes.object,
|
|
203
|
-
/**
|
|
204
|
-
* By default, if showUserLocation is true, a transparent circle will be drawn around the user location
|
|
205
|
-
* indicating the accuracy (95% confidence level) of the user's location. Set to false to disable.
|
|
206
|
-
*/
|
|
207
|
-
showAccuracyCircle: PropTypes.bool,
|
|
208
|
-
/**
|
|
209
|
-
* By default a dot will be shown on the map at the user's location. Set to false to disable.
|
|
210
|
-
*/
|
|
211
|
-
showUserLocation: PropTypes.bool,
|
|
212
|
-
/**
|
|
213
|
-
* By default a cone will be shown on the map at the user's location to indicate the device's orientation.
|
|
214
|
-
* Set to false to disable.
|
|
215
|
-
*/
|
|
216
|
-
showOrientation: PropTypes.bool,
|
|
217
|
-
};
|
|
218
231
|
export default MlFollowGps;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useRef, useEffect, useState } from "react";
|
|
2
|
-
import
|
|
3
|
-
import { bbox } from "@turf/turf";
|
|
2
|
+
import { bbox } from '@turf/turf';
|
|
4
3
|
import Divider from "@mui/material/Divider";
|
|
5
4
|
import Typography from "@mui/material/Typography";
|
|
6
5
|
import Drawer from "@mui/material/Drawer";
|
|
7
6
|
import IconButton from "@mui/material/IconButton";
|
|
8
7
|
import InfoIcon from "@mui/icons-material/Info";
|
|
9
8
|
import FileCopy from "@mui/icons-material/FileCopy";
|
|
10
|
-
import { Popup } from "maplibre-gl";
|
|
9
|
+
import { Popup, LngLatBoundsLike, GeoJSONSource } from "maplibre-gl";
|
|
11
10
|
import List from "@mui/material/List";
|
|
12
11
|
import ListItem from "@mui/material/ListItem";
|
|
13
12
|
import ListItemText from "@mui/material/ListItemText";
|
|
@@ -16,12 +15,31 @@ import toGeoJSON from "./gpxConverter";
|
|
|
16
15
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
17
16
|
import useMap from "../../hooks/useMap";
|
|
18
17
|
|
|
18
|
+
interface MlGPXViewerProps {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Id of the target MapLibre instance in mapHook
|
|
22
|
+
*/
|
|
23
|
+
mapId?: string,
|
|
24
|
+
/**
|
|
25
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
26
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
27
|
+
*/
|
|
28
|
+
insertBeforeLayer?: string,
|
|
29
|
+
/**
|
|
30
|
+
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
31
|
+
*/
|
|
32
|
+
idPrefix?: string,
|
|
33
|
+
/**
|
|
34
|
+
* Sets the layers layout-property "visibility" to "none" if false or "visible" if true
|
|
35
|
+
*/
|
|
36
|
+
visible?: boolean,
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
/**
|
|
20
40
|
* MlGPXViewer returns a dropzone and a button to load a GPX Track into the map.
|
|
21
|
-
*
|
|
22
|
-
* @component
|
|
23
41
|
*/
|
|
24
|
-
const MlGPXViewer = (props) => {
|
|
42
|
+
const MlGPXViewer = (props:MlGPXViewerProps) => {
|
|
25
43
|
const dataSource = useContext(GeoJsonContext);
|
|
26
44
|
const initializedRef = useRef(false);
|
|
27
45
|
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
@@ -30,10 +48,10 @@ const MlGPXViewer = (props) => {
|
|
|
30
48
|
const layerNamePoints = "importer-layer-points";
|
|
31
49
|
|
|
32
50
|
const [open, setIsOpen] = useState(false);
|
|
33
|
-
const dropZone = useRef(null);
|
|
51
|
+
const dropZone = useRef<HTMLDivElement>(null);
|
|
34
52
|
const [zIndex, setZIndex] = useState(0);
|
|
35
|
-
const [metaData, setMetaData] = useState([]);
|
|
36
|
-
const fileupload = useRef(null);
|
|
53
|
+
const [metaData, setMetaData] = useState<{ title: string; value: string; id: number; }[]>([]);
|
|
54
|
+
const fileupload = useRef<HTMLInputElement>(null);
|
|
37
55
|
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
38
56
|
|
|
39
57
|
const popup = useRef(
|
|
@@ -85,12 +103,15 @@ const MlGPXViewer = (props) => {
|
|
|
85
103
|
);
|
|
86
104
|
|
|
87
105
|
[layerNameLines, layerNamePoints].forEach((layerName) => {
|
|
88
|
-
mapHook.map
|
|
106
|
+
if(!mapHook.map)return;
|
|
107
|
+
|
|
108
|
+
mapHook.map.map.setLayoutProperty(layerName, "visibility", "visible");
|
|
89
109
|
});
|
|
90
110
|
mapHook.map.on(
|
|
91
111
|
"mouseenter",
|
|
92
112
|
layerNamePoints,
|
|
93
|
-
(e) => {
|
|
113
|
+
(e:any) => {
|
|
114
|
+
if(!mapHook.map)return;
|
|
94
115
|
// Change the cursor style as a UI indicator.
|
|
95
116
|
|
|
96
117
|
const coordinates = e.features[0].geometry.coordinates.slice();
|
|
@@ -107,7 +128,7 @@ const MlGPXViewer = (props) => {
|
|
|
107
128
|
// Populate the popup and set its coordinates
|
|
108
129
|
|
|
109
130
|
// based on the feature found.
|
|
110
|
-
popup.current.setLngLat(coordinates).setHTML(name).addTo(mapHook.map);
|
|
131
|
+
popup.current.setLngLat(coordinates).setHTML(name).addTo(mapHook.map.map);
|
|
111
132
|
},
|
|
112
133
|
mapHook.componentId
|
|
113
134
|
);
|
|
@@ -116,25 +137,27 @@ const MlGPXViewer = (props) => {
|
|
|
116
137
|
"mouseleave",
|
|
117
138
|
"places",
|
|
118
139
|
function () {
|
|
119
|
-
mapHook.map
|
|
140
|
+
if(!mapHook.map)return;
|
|
141
|
+
|
|
142
|
+
mapHook.map.map.getCanvas().style.cursor = "";
|
|
120
143
|
popup.current.remove();
|
|
121
144
|
},
|
|
122
145
|
mapHook.componentId
|
|
123
146
|
);
|
|
124
147
|
|
|
125
|
-
mapHook.map.setZoom(10);
|
|
148
|
+
mapHook.map.map.setZoom(10);
|
|
126
149
|
}, [mapHook.map]);
|
|
127
150
|
|
|
128
151
|
useEffect(() => {
|
|
129
|
-
const
|
|
130
|
-
const raiseDropZoneAndStopDefault = (event) => {
|
|
152
|
+
const _dropZone = dropZone.current;
|
|
153
|
+
const raiseDropZoneAndStopDefault = (event:any) => {
|
|
131
154
|
setZIndex(1000);
|
|
132
155
|
stopDefault(event);
|
|
133
156
|
};
|
|
134
157
|
const lowerDropZone = () => {
|
|
135
158
|
setZIndex(0);
|
|
136
159
|
};
|
|
137
|
-
const lowerDropZoneAndStopDefault = (event) => {
|
|
160
|
+
const lowerDropZoneAndStopDefault = (event:any) => {
|
|
138
161
|
setZIndex(0);
|
|
139
162
|
stopDefault(event);
|
|
140
163
|
};
|
|
@@ -142,19 +165,19 @@ const MlGPXViewer = (props) => {
|
|
|
142
165
|
window.addEventListener("dragenter", raiseDropZoneAndStopDefault);
|
|
143
166
|
window.addEventListener("dragover", stopDefault);
|
|
144
167
|
|
|
145
|
-
|
|
168
|
+
_dropZone?.addEventListener("dragleave", lowerDropZone);
|
|
146
169
|
|
|
147
170
|
window.addEventListener("drop", lowerDropZoneAndStopDefault);
|
|
148
171
|
|
|
149
172
|
return () => {
|
|
150
173
|
window.removeEventListener("dragenter", raiseDropZoneAndStopDefault);
|
|
151
174
|
window.removeEventListener("dragover", stopDefault);
|
|
152
|
-
|
|
175
|
+
_dropZone?.removeEventListener("dragleave", lowerDropZone);
|
|
153
176
|
window.removeEventListener("drop", lowerDropZoneAndStopDefault);
|
|
154
177
|
};
|
|
155
178
|
});
|
|
156
179
|
|
|
157
|
-
const stopDefault = (event) => {
|
|
180
|
+
const stopDefault = (event:any) => {
|
|
158
181
|
event.preventDefault();
|
|
159
182
|
event.stopPropagation();
|
|
160
183
|
};
|
|
@@ -165,11 +188,13 @@ const MlGPXViewer = (props) => {
|
|
|
165
188
|
const visibility = props.visible ? "visible" : "none";
|
|
166
189
|
|
|
167
190
|
[layerNameLines, layerNamePoints].forEach((layerName) => {
|
|
168
|
-
mapHook.map
|
|
191
|
+
if(!mapHook.map)return;
|
|
192
|
+
|
|
193
|
+
mapHook.map.map.setLayoutProperty(layerName, "visibility", visibility);
|
|
169
194
|
});
|
|
170
195
|
}, [props.visible]);
|
|
171
196
|
|
|
172
|
-
const dropHandler = (event) => {
|
|
197
|
+
const dropHandler = (event:any) => {
|
|
173
198
|
event.preventDefault();
|
|
174
199
|
|
|
175
200
|
if (event.dataTransfer.items) {
|
|
@@ -179,7 +204,9 @@ const MlGPXViewer = (props) => {
|
|
|
179
204
|
// If dropped items aren't files, reject them
|
|
180
205
|
if (event.dataTransfer.items[0].kind === "file") {
|
|
181
206
|
const reader = new FileReader();
|
|
182
|
-
reader.onload = (payload) => {
|
|
207
|
+
reader.onload = (payload:any) => {
|
|
208
|
+
if(!payload?.currentTarget?.result)return;
|
|
209
|
+
|
|
183
210
|
addGPXToMap(payload.currentTarget.result);
|
|
184
211
|
};
|
|
185
212
|
const file = event.dataTransfer.items[0].getAsFile();
|
|
@@ -188,23 +215,25 @@ const MlGPXViewer = (props) => {
|
|
|
188
215
|
} else {
|
|
189
216
|
// Use DataTransfer interface to access the file(s)
|
|
190
217
|
}
|
|
218
|
+
return;
|
|
191
219
|
};
|
|
192
220
|
|
|
193
|
-
const addGPXToMap = (gpxAsString) => {
|
|
194
|
-
if (!mapHook.map) return;
|
|
221
|
+
const addGPXToMap = (gpxAsString:string) => {
|
|
222
|
+
if (!mapHook.map || !dataSource.setData) return;
|
|
223
|
+
|
|
195
224
|
try {
|
|
196
225
|
setMetaData([]);
|
|
197
226
|
const domParser = new DOMParser();
|
|
198
227
|
const gpxDoc = domParser.parseFromString(gpxAsString, "application/xml");
|
|
199
228
|
const metadata = gpxDoc.querySelector("metadata");
|
|
200
|
-
metadata
|
|
229
|
+
metadata?.childNodes.forEach((node:Element) => {
|
|
201
230
|
let value = node.textContent;
|
|
202
231
|
const title = node.nodeName;
|
|
203
232
|
|
|
204
233
|
if (node.nodeName === "link") {
|
|
205
234
|
value = node.getAttribute("href");
|
|
206
235
|
}
|
|
207
|
-
if (!!value
|
|
236
|
+
if (!!value?.trim().length) {
|
|
208
237
|
const metaDatEntry = {
|
|
209
238
|
title: title,
|
|
210
239
|
value: value,
|
|
@@ -215,9 +244,9 @@ const MlGPXViewer = (props) => {
|
|
|
215
244
|
});
|
|
216
245
|
const data = toGeoJSON.gpx(gpxDoc);
|
|
217
246
|
dataSource.setData(data);
|
|
218
|
-
mapHook.map.getSource(sourceName).setData(data);
|
|
247
|
+
(mapHook.map.map.getSource(sourceName) as GeoJSONSource).setData(data as GeoJSON);
|
|
219
248
|
const bounds = bbox(data);
|
|
220
|
-
mapHook.map.fitBounds(bounds);
|
|
249
|
+
mapHook.map.map.fitBounds(bounds as LngLatBoundsLike);
|
|
221
250
|
} catch (e) {
|
|
222
251
|
console.log(e);
|
|
223
252
|
}
|
|
@@ -228,17 +257,25 @@ const MlGPXViewer = (props) => {
|
|
|
228
257
|
};
|
|
229
258
|
|
|
230
259
|
const fileUploadOnChange = () => {
|
|
231
|
-
|
|
260
|
+
if(!fileupload.current)return false;
|
|
261
|
+
|
|
262
|
+
const file = fileupload.current?.files?.[0];
|
|
232
263
|
if (!file) return false;
|
|
233
264
|
const reader = new FileReader();
|
|
234
|
-
reader.onload = (payload) => {
|
|
265
|
+
reader.onload = (payload:any) => {
|
|
266
|
+
if(!payload)return;
|
|
267
|
+
|
|
235
268
|
addGPXToMap(payload.currentTarget.result);
|
|
236
269
|
};
|
|
237
270
|
|
|
238
271
|
reader.readAsText(file);
|
|
272
|
+
|
|
273
|
+
return;
|
|
239
274
|
};
|
|
240
275
|
|
|
241
276
|
const manualUpload = () => {
|
|
277
|
+
if(!fileupload.current)return;
|
|
278
|
+
|
|
242
279
|
fileupload.current.click();
|
|
243
280
|
};
|
|
244
281
|
return (
|
|
@@ -336,24 +373,5 @@ MlGPXViewer.defaultProps = {
|
|
|
336
373
|
visible: true,
|
|
337
374
|
};
|
|
338
375
|
|
|
339
|
-
MlGPXViewer.propTypes = {
|
|
340
|
-
/**
|
|
341
|
-
* Id of the target MapLibre instance in mapHook
|
|
342
|
-
*/
|
|
343
|
-
mapId: PropTypes.string,
|
|
344
|
-
/**
|
|
345
|
-
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
346
|
-
*/
|
|
347
|
-
idPrefix: PropTypes.string,
|
|
348
|
-
/**
|
|
349
|
-
* Sets the layers layout-property "visibility" to "none" if false or "visible" if true
|
|
350
|
-
*/
|
|
351
|
-
visible: PropTypes.bool,
|
|
352
|
-
/**
|
|
353
|
-
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
354
|
-
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
355
|
-
*/
|
|
356
|
-
insertBeforeLayer: PropTypes.string,
|
|
357
|
-
};
|
|
358
376
|
|
|
359
377
|
export default MlGPXViewer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FeatureCollection } from '@turf/turf';
|
|
3
|
+
|
|
4
|
+
type ContextProps = {
|
|
5
|
+
data: FeatureCollection,
|
|
6
|
+
setData: Function,
|
|
7
|
+
getEmptyFeatureCollection: Function
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const GeoJsonContext = React.createContext<Partial<ContextProps>>({});
|
|
11
|
+
|
|
12
|
+
export const GeoJsonContextProvider = GeoJsonContext.Provider;
|
|
13
|
+
export default GeoJsonContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { GeoJsonContextProvider } from "./GeoJsonContext";
|
|
3
|
+
import { FeatureCollection } from '@turf/turf';
|
|
4
4
|
|
|
5
|
-
const GeoJsonProvider = ({ children }) => {
|
|
6
|
-
const [data, setData] = useState({
|
|
5
|
+
const GeoJsonProvider = ({ children }:{children:JSX.Element}) => {
|
|
6
|
+
const [data, setData] = useState<FeatureCollection>({
|
|
7
7
|
type: "FeatureCollection",
|
|
8
8
|
features: [],
|
|
9
9
|
});
|
|
@@ -22,8 +22,4 @@ const GeoJsonProvider = ({ children }) => {
|
|
|
22
22
|
return <GeoJsonContextProvider value={value}>{children}</GeoJsonContextProvider>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
GeoJsonProvider.propTypes = {
|
|
26
|
-
children: PropTypes.node.isRequired,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
25
|
export default GeoJsonProvider;
|
|
@@ -12,8 +12,6 @@ const storyoptions = {
|
|
|
12
12
|
title: "MapComponents/MlGeoJsonLayer",
|
|
13
13
|
component: MlGeoJsonLayer,
|
|
14
14
|
argTypes: {
|
|
15
|
-
url: {},
|
|
16
|
-
layer: {},
|
|
17
15
|
},
|
|
18
16
|
decorators: mapContextDecorator,
|
|
19
17
|
};
|
|
@@ -36,12 +34,18 @@ const LinestringTemplate = (props) => {
|
|
|
36
34
|
|
|
37
35
|
export const Linestring = LinestringTemplate.bind({});
|
|
38
36
|
Linestring.parameters = {};
|
|
39
|
-
Linestring.args = {
|
|
37
|
+
Linestring.args = {
|
|
38
|
+
type:''
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
export const Polygon = Template.bind({});
|
|
42
42
|
Polygon.parameters = {};
|
|
43
43
|
Polygon.args = {
|
|
44
44
|
geojson: sample_polygon_geojson_1,
|
|
45
|
+
paint:{
|
|
46
|
+
"fill-color": 'rgba(120,20,80,.5)'
|
|
47
|
+
},
|
|
48
|
+
type:''
|
|
45
49
|
};
|
|
46
50
|
export const DefaultPaintOverrides = Template.bind({});
|
|
47
51
|
DefaultPaintOverrides.parameters = {};
|
|
@@ -58,4 +62,5 @@ DefaultPaintOverrides.args = {
|
|
|
58
62
|
},
|
|
59
63
|
},
|
|
60
64
|
geojson: sample_polygon_geojson_1,
|
|
65
|
+
type:''
|
|
61
66
|
};
|