@mapcomponents/react-maplibre 0.1.34 → 0.1.35
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 +6 -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 +17049 -4280
- 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 +132 -115
- 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,106 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import useLayer from "../../hooks/useLayer";
|
|
4
|
+
|
|
5
|
+
import { v4 as uuidv4 } from "uuid";
|
|
6
|
+
|
|
7
|
+
import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
8
|
+
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
9
|
+
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
|
+
|
|
11
|
+
type MlGeoJsonLayerProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Id of the target MapLibre instance in mapContext
|
|
14
|
+
*/
|
|
15
|
+
mapId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
18
|
+
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
19
|
+
*/
|
|
20
|
+
insertBeforeLayer?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Id of the new layer and source that are added to the MapLibre instance
|
|
23
|
+
*/
|
|
24
|
+
layerId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
27
|
+
*/
|
|
28
|
+
geojson: Feature | FeatureCollection | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Type of the layer that will be added to the MapLibre instance.
|
|
31
|
+
* Possible values: "line", "circle", "fill"
|
|
32
|
+
*/
|
|
33
|
+
type?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Paint property object, that is passed to the addLayer call.
|
|
36
|
+
* Possible props depend on the layer type.
|
|
37
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
38
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
39
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
40
|
+
*/
|
|
41
|
+
paint?: any;
|
|
42
|
+
/**
|
|
43
|
+
* Layout property object, that is passed to the addLayer call.
|
|
44
|
+
* Possible props depend on the layer type.
|
|
45
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
46
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
47
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
48
|
+
*/
|
|
49
|
+
layout?: any;
|
|
50
|
+
/**
|
|
51
|
+
* Javascript object that is spread into the addLayer commands first parameter.
|
|
52
|
+
*/
|
|
53
|
+
options?: any;
|
|
54
|
+
/**
|
|
55
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
56
|
+
*/
|
|
57
|
+
defaultPaintOverrides?: any;
|
|
58
|
+
/**
|
|
59
|
+
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
60
|
+
*/
|
|
61
|
+
onHover?: Function;
|
|
62
|
+
/**
|
|
63
|
+
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
64
|
+
*/
|
|
65
|
+
onClick?: Function;
|
|
66
|
+
/**
|
|
67
|
+
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
68
|
+
* left/unhovered.
|
|
69
|
+
*/
|
|
70
|
+
onLeave?: Function;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
75
|
+
*
|
|
76
|
+
* @component
|
|
77
|
+
*/
|
|
78
|
+
const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => {
|
|
79
|
+
const layerType = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
80
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
81
|
+
useLayer({
|
|
82
|
+
mapId: props.mapId,
|
|
83
|
+
layerId: props.layerId || "MlGeoJsonLayer-" + uuidv4(),
|
|
84
|
+
geojson: props.geojson,
|
|
85
|
+
options: {
|
|
86
|
+
paint:
|
|
87
|
+
props.paint ||
|
|
88
|
+
getDefaultPaintPropsByType(
|
|
89
|
+
layerType,
|
|
90
|
+
props.defaultPaintOverrides
|
|
91
|
+
),
|
|
92
|
+
layout: props.layout || {},
|
|
93
|
+
...props.options,
|
|
94
|
+
type: layerType,
|
|
95
|
+
},
|
|
96
|
+
insertBeforeLayer: props.insertBeforeLayer,
|
|
97
|
+
onHover: props.onHover,
|
|
98
|
+
onClick: props.onClick,
|
|
99
|
+
onLeave: props.onLeave,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return (<></>);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export default MlGeoJsonLayer;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Feature, FeatureCollection } from "@turf/turf";
|
|
2
|
+
|
|
1
3
|
const mapGeometryTypesToLayerTypes = {
|
|
2
4
|
Position: "circle",
|
|
3
5
|
Point: "circle",
|
|
@@ -9,7 +11,9 @@ const mapGeometryTypesToLayerTypes = {
|
|
|
9
11
|
GeometryCollection: "circle",
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
const getDefaulLayerTypeByGeometry = (
|
|
14
|
+
const getDefaulLayerTypeByGeometry: Function = (
|
|
15
|
+
geojson: Feature | FeatureCollection
|
|
16
|
+
): string => {
|
|
13
17
|
if (geojson?.type === "Feature") {
|
|
14
18
|
return mapGeometryTypesToLayerTypes?.[geojson?.geometry?.type]
|
|
15
19
|
? mapGeometryTypesToLayerTypes[geojson.geometry.type]
|
|
@@ -21,5 +25,6 @@ const getDefaulLayerTypeByGeometry = (geojson) => {
|
|
|
21
25
|
}
|
|
22
26
|
return "circle";
|
|
23
27
|
}
|
|
28
|
+
return "fill";
|
|
24
29
|
};
|
|
25
30
|
export default getDefaulLayerTypeByGeometry;
|
|
@@ -8,10 +8,7 @@ import wgMarker from "./assets/wg-marker.png";
|
|
|
8
8
|
const storyoptions = {
|
|
9
9
|
title: "MapComponents/MlImageMarkerLayer",
|
|
10
10
|
component: MlImageMarkerLayer,
|
|
11
|
-
argTypes: {
|
|
12
|
-
url: {},
|
|
13
|
-
layer: {},
|
|
14
|
-
},
|
|
11
|
+
argTypes: { },
|
|
15
12
|
decorators: mapContextDecorator,
|
|
16
13
|
};
|
|
17
14
|
export default storyoptions;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { useRef, useCallback, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { GeoJSONSource } from "maplibre-gl";
|
|
4
|
+
import useMap from "../../hooks/useMap";
|
|
5
|
+
|
|
6
|
+
interface MlImageMarkerLayerProps {
|
|
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 to the maplibre-gl instance
|
|
18
|
+
*/
|
|
19
|
+
layerId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Id of the image that will be added by this component to the maplibre-gl instance
|
|
22
|
+
*/
|
|
23
|
+
imageId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Path or URL to a supported raster image
|
|
26
|
+
*/
|
|
27
|
+
imgSrc?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Javascript object that is passed the addLayer command as first parameter.
|
|
30
|
+
*/
|
|
31
|
+
options?: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const MlImageMarkerLayer = (props: MlImageMarkerLayerProps) => {
|
|
35
|
+
const mapHook = useMap({
|
|
36
|
+
mapId: props.mapId,
|
|
37
|
+
waitForLayer: props.insertBeforeLayer,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const layerInitializedRef = useRef(false);
|
|
41
|
+
const imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
42
|
+
const layerId = useRef(
|
|
43
|
+
props.layerId || "MlImageMarkerLayer-" + mapHook.componentId
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (
|
|
48
|
+
!mapHook.map ||
|
|
49
|
+
(mapHook.map && !mapHook.map.map.getLayer(layerId.current)) ||
|
|
50
|
+
!props.options
|
|
51
|
+
)
|
|
52
|
+
return;
|
|
53
|
+
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
54
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
55
|
+
var key;
|
|
56
|
+
|
|
57
|
+
if (props.options.layout) {
|
|
58
|
+
for (key in props.options.layout) {
|
|
59
|
+
mapHook.map.map.setLayoutProperty(
|
|
60
|
+
layerId.current,
|
|
61
|
+
key,
|
|
62
|
+
props.options.layout[key]
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (props.options.paint) {
|
|
67
|
+
for (key in props.options.paint) {
|
|
68
|
+
mapHook.map.map.setPaintProperty(
|
|
69
|
+
layerId.current,
|
|
70
|
+
key,
|
|
71
|
+
props.options.paint[key]
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [props.options, layerId.current, props.mapId]);
|
|
76
|
+
|
|
77
|
+
const addLayer = useCallback(() => {
|
|
78
|
+
if(!mapHook.map)return;
|
|
79
|
+
|
|
80
|
+
let tmpOptions = {
|
|
81
|
+
id: layerId.current,
|
|
82
|
+
layout: {},
|
|
83
|
+
...props.options,
|
|
84
|
+
};
|
|
85
|
+
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
86
|
+
mapHook.map.addLayer(
|
|
87
|
+
tmpOptions,
|
|
88
|
+
props.insertBeforeLayer,
|
|
89
|
+
mapHook.componentId
|
|
90
|
+
);
|
|
91
|
+
}, [props, mapHook.map]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!props.options || !mapHook.map || layerInitializedRef.current)
|
|
95
|
+
return;
|
|
96
|
+
|
|
97
|
+
layerInitializedRef.current = true;
|
|
98
|
+
|
|
99
|
+
if (props.imgSrc) {
|
|
100
|
+
mapHook.map.map.loadImage(props.imgSrc, function (error, image) {
|
|
101
|
+
if (error) throw error;
|
|
102
|
+
|
|
103
|
+
if(!mapHook.map)return;
|
|
104
|
+
|
|
105
|
+
mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
addLayer();
|
|
110
|
+
}, [mapHook.map, addLayer, props]);
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (
|
|
114
|
+
!mapHook.map ||
|
|
115
|
+
(mapHook.map && !mapHook.map.map.getLayer(layerId.current)) ||
|
|
116
|
+
!props.options
|
|
117
|
+
) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
(mapHook.map.map
|
|
122
|
+
.getSource(layerId.current) as GeoJSONSource)
|
|
123
|
+
.setData(props.options.source.data);
|
|
124
|
+
}, [props.options.source.data, props]);
|
|
125
|
+
|
|
126
|
+
return <></>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default MlImageMarkerLayer;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import useLayer from "../../hooks/useLayer";
|
|
4
|
+
|
|
5
|
+
interface MlLayerProps {
|
|
6
|
+
/**
|
|
7
|
+
* Id of the target MapLibre instance in mapContext
|
|
8
|
+
*/
|
|
9
|
+
mapId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
12
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
13
|
+
*/
|
|
14
|
+
insertBeforeLayer?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Id of the layer that will be added by this component to the maplibre-gl instance
|
|
17
|
+
*/
|
|
18
|
+
layerId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Javascript object that is passed the addLayer command as first parameter.
|
|
21
|
+
*/
|
|
22
|
+
options?: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Basic layer component that create a layer in a MapLibre-gl instance and keeps it updated according to it attribute configuration.
|
|
27
|
+
*
|
|
28
|
+
* @category Map components
|
|
29
|
+
*/
|
|
30
|
+
const MlLayer = (props: MlLayerProps) => {
|
|
31
|
+
useLayer({
|
|
32
|
+
idPrefix: 'MlLayer-',
|
|
33
|
+
layerId: props.layerId,
|
|
34
|
+
mapId: props.mapId,
|
|
35
|
+
options: {
|
|
36
|
+
type: "background",
|
|
37
|
+
paint: {
|
|
38
|
+
"background-color": "rgba(0,0,0,0)",
|
|
39
|
+
},
|
|
40
|
+
...props.options,
|
|
41
|
+
},
|
|
42
|
+
insertBeforeLayer: props.insertBeforeLayer,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return <></>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default MlLayer;
|
|
@@ -9,8 +9,6 @@ const storyoptions = {
|
|
|
9
9
|
title: "MapComponents/MlLayerMagnify",
|
|
10
10
|
component: MlLayerMagnify,
|
|
11
11
|
argTypes: {
|
|
12
|
-
url: {},
|
|
13
|
-
layer: {},
|
|
14
12
|
},
|
|
15
13
|
decorators: multiMapContextDecorator,
|
|
16
14
|
};
|
|
@@ -34,7 +32,9 @@ const Template = (args) => (
|
|
|
34
32
|
);
|
|
35
33
|
|
|
36
34
|
export const ExampleConfig = Template.bind({});
|
|
37
|
-
ExampleConfig.parameters = {
|
|
35
|
+
ExampleConfig.parameters = {
|
|
36
|
+
|
|
37
|
+
};
|
|
38
38
|
ExampleConfig.args = {
|
|
39
39
|
wmsLayerMapId: "map_2",
|
|
40
40
|
magnifierRadius: 200,
|
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
useContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
useMemo
|
|
8
|
+
} from "react";
|
|
9
|
+
// @ts-ignore
|
|
3
10
|
import syncMove from "@mapbox/mapbox-gl-sync-move";
|
|
4
11
|
import "./style.css";
|
|
12
|
+
// @ts-ignore
|
|
5
13
|
import { MapContext } from "@mapcomponents/react-core";
|
|
6
14
|
|
|
15
|
+
interface MlLayerMagnifyProps {
|
|
16
|
+
/**
|
|
17
|
+
* Id of the first MapLibre instance
|
|
18
|
+
*/
|
|
19
|
+
map1Id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Id of the second MapLibre instance
|
|
22
|
+
*/
|
|
23
|
+
map2Id: string;
|
|
24
|
+
/**
|
|
25
|
+
* Size of the "magnifier"-circle
|
|
26
|
+
*/
|
|
27
|
+
magnifierRadius?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
7
30
|
/**
|
|
8
31
|
*
|
|
9
32
|
* Hides the MapLibreMap referenced by props.map2Id except for the "magnifier"-circle that reveals
|
|
10
33
|
* the map and can be dragged around on top of the MapLibreMap referenced by props.map1Id
|
|
11
|
-
*
|
|
12
|
-
* @component
|
|
13
34
|
*/
|
|
14
|
-
const MlLayerMagnify = (props) => {
|
|
15
|
-
const mapContext = useContext(MapContext);
|
|
35
|
+
const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
36
|
+
const mapContext:MapContextType = useContext(MapContext);
|
|
16
37
|
const syncMoveInitializedRef = useRef(false);
|
|
17
38
|
const syncCleanupFunctionRef = useRef(null);
|
|
18
39
|
|
|
19
|
-
const [swipeX, setSwipeX] = useState(50);
|
|
20
|
-
const swipeXRef = useRef(50);
|
|
21
|
-
const [swipeY, setSwipeY] = useState(50);
|
|
22
|
-
const swipeYRef = useRef(50);
|
|
40
|
+
const [swipeX, setSwipeX] = useState('50');
|
|
41
|
+
const swipeXRef = useRef('50');
|
|
42
|
+
const [swipeY, setSwipeY] = useState('50');
|
|
43
|
+
const swipeYRef = useRef('50');
|
|
23
44
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
const magnifierRadius = useMemo(() => {
|
|
46
|
+
return props.magnifierRadius || 200;
|
|
47
|
+
},[props.magnifierRadius]);
|
|
27
48
|
|
|
28
49
|
const mapExists = useCallback(() => {
|
|
29
50
|
if (!props.map1Id || !props.map2Id) {
|
|
@@ -51,7 +72,8 @@ const MlLayerMagnify = (props) => {
|
|
|
51
72
|
|
|
52
73
|
return () => {
|
|
53
74
|
window.removeEventListener("resize", _onResize);
|
|
54
|
-
if (syncCleanupFunctionRef.current) {
|
|
75
|
+
if (typeof syncCleanupFunctionRef.current === 'function') {
|
|
76
|
+
// @ts-ignore
|
|
55
77
|
syncCleanupFunctionRef.current();
|
|
56
78
|
}
|
|
57
79
|
};
|
|
@@ -61,7 +83,9 @@ const MlLayerMagnify = (props) => {
|
|
|
61
83
|
(e) => {
|
|
62
84
|
if (!mapExists()) return;
|
|
63
85
|
|
|
64
|
-
let bounds = mapContext.maps[props.map1Id]
|
|
86
|
+
let bounds = mapContext.maps[props.map1Id]
|
|
87
|
+
.getCanvas()
|
|
88
|
+
.getBoundingClientRect();
|
|
65
89
|
let clientX =
|
|
66
90
|
e.clientX ||
|
|
67
91
|
(typeof e.touches !== "undefined" && typeof e.touches[0] !== "undefined"
|
|
@@ -78,21 +102,24 @@ const MlLayerMagnify = (props) => {
|
|
|
78
102
|
let swipeX_tmp = ((clientX / bounds.width) * 100).toFixed(2);
|
|
79
103
|
let swipeY_tmp = ((clientY / bounds.height) * 100).toFixed(2);
|
|
80
104
|
|
|
81
|
-
if (
|
|
105
|
+
if (
|
|
106
|
+
swipeXRef.current !== swipeX_tmp ||
|
|
107
|
+
swipeYRef.current !== swipeY_tmp
|
|
108
|
+
) {
|
|
82
109
|
setSwipeX(swipeX_tmp);
|
|
83
110
|
swipeXRef.current = swipeX_tmp;
|
|
84
111
|
setSwipeY(swipeY_tmp);
|
|
85
112
|
swipeYRef.current = swipeY_tmp;
|
|
86
113
|
|
|
87
114
|
mapContext.maps[props.map2Id].getContainer().style.clipPath =
|
|
88
|
-
`circle(${
|
|
89
|
-
(swipeXRef.current * bounds.width) / 100 +
|
|
115
|
+
`circle(${magnifierRadius}px at ` +
|
|
116
|
+
(parseFloat(swipeXRef.current) * bounds.width) / 100 +
|
|
90
117
|
"px " +
|
|
91
|
-
(swipeYRef.current * bounds.height) / 100 +
|
|
118
|
+
(parseFloat(swipeYRef.current) * bounds.height) / 100 +
|
|
92
119
|
"px)";
|
|
93
120
|
}
|
|
94
121
|
},
|
|
95
|
-
[mapContext, mapExists, props]
|
|
122
|
+
[mapContext, mapExists, props, magnifierRadius]
|
|
96
123
|
);
|
|
97
124
|
|
|
98
125
|
useEffect(() => {
|
|
@@ -104,27 +131,32 @@ const MlLayerMagnify = (props) => {
|
|
|
104
131
|
mapContext.getMap(props.map2Id).map
|
|
105
132
|
);
|
|
106
133
|
|
|
134
|
+
/*
|
|
135
|
+
automatically adjust radius for small screens
|
|
107
136
|
if (
|
|
108
137
|
mapContext.maps[props.map1Id].getCanvas().clientWidth >
|
|
109
138
|
mapContext.maps[props.map1Id].getCanvas().clientHeight &&
|
|
110
|
-
|
|
139
|
+
magnifierRadius * 2 >
|
|
140
|
+
mapContext.maps[props.map1Id].getCanvas().clientHeight
|
|
111
141
|
) {
|
|
112
|
-
|
|
142
|
+
magnifierRadius = Math.floor(
|
|
113
143
|
mapContext.maps[props.map1Id].getCanvas().clientHeight / 2
|
|
114
144
|
);
|
|
115
|
-
setMagnifierRadius(
|
|
145
|
+
setMagnifierRadius(magnifierRadius);
|
|
116
146
|
}
|
|
117
147
|
|
|
118
148
|
if (
|
|
119
149
|
mapContext.maps[props.map1Id].getCanvas().clientHeight >
|
|
120
150
|
mapContext.maps[props.map1Id].getCanvas().clientWidth &&
|
|
121
|
-
|
|
151
|
+
magnifierRadius * 2 >
|
|
152
|
+
mapContext.maps[props.map1Id].getCanvas().clientWidth
|
|
122
153
|
) {
|
|
123
|
-
|
|
154
|
+
magnifierRadius = Math.floor(
|
|
124
155
|
mapContext.maps[props.map1Id].getCanvas().clientWidth / 2
|
|
125
156
|
);
|
|
126
|
-
setMagnifierRadius(
|
|
157
|
+
setMagnifierRadius(magnifierRadius);
|
|
127
158
|
}
|
|
159
|
+
*/
|
|
128
160
|
|
|
129
161
|
onMove({
|
|
130
162
|
clientX: mapContext.maps[props.map1Id].getCanvas().clientWidth / 2,
|
|
@@ -132,7 +164,7 @@ const MlLayerMagnify = (props) => {
|
|
|
132
164
|
});
|
|
133
165
|
}, [mapContext.mapIds, mapContext, mapExists, props, onMove]);
|
|
134
166
|
|
|
135
|
-
const onDown = (e) => {
|
|
167
|
+
const onDown = (e:any) => {
|
|
136
168
|
if (e.touches) {
|
|
137
169
|
document.addEventListener("touchmove", onMove);
|
|
138
170
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -152,7 +184,7 @@ const MlLayerMagnify = (props) => {
|
|
|
152
184
|
document.removeEventListener("mouseup", onMouseUp);
|
|
153
185
|
};
|
|
154
186
|
|
|
155
|
-
const onWheel = (e) => {
|
|
187
|
+
const onWheel = (e:any) => {
|
|
156
188
|
let evCopy = new WheelEvent(e.type, e);
|
|
157
189
|
mapContext.map.getCanvas().dispatchEvent(evCopy);
|
|
158
190
|
};
|
|
@@ -168,7 +200,8 @@ const MlLayerMagnify = (props) => {
|
|
|
168
200
|
height: magnifierRadius * 2 + 1 + "px",
|
|
169
201
|
background: "rgba(0,0,0,0)",
|
|
170
202
|
border: "2px solid #fafafa",
|
|
171
|
-
boxShadow:
|
|
203
|
+
boxShadow:
|
|
204
|
+
"1px 2px 2px rgba(19, 19, 19, .5), inset 1px 1px 1px rgba(19, 19, 19, .2)",
|
|
172
205
|
cursor: "pointer",
|
|
173
206
|
zIndex: "110",
|
|
174
207
|
marginLeft: magnifierRadius * -1 - 1 + "px",
|
|
@@ -190,18 +223,4 @@ MlLayerMagnify.defaultProps = {
|
|
|
190
223
|
magnifierRadius: 200,
|
|
191
224
|
};
|
|
192
225
|
|
|
193
|
-
MlLayerMagnify.propTypes = {
|
|
194
|
-
/**
|
|
195
|
-
* Id of the first MapLibre instance
|
|
196
|
-
*/
|
|
197
|
-
map1Id: PropTypes.string,
|
|
198
|
-
/**
|
|
199
|
-
* Id of the second MapLibre instance
|
|
200
|
-
*/
|
|
201
|
-
map2Id: PropTypes.string,
|
|
202
|
-
/**
|
|
203
|
-
* Size of the "magnifier"-circle
|
|
204
|
-
*/
|
|
205
|
-
magnifierRadius: PropTypes.number,
|
|
206
|
-
};
|
|
207
226
|
export default MlLayerMagnify;
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
8
|
+
// @ts-ignore
|
|
2
9
|
import syncMove from "@mapbox/mapbox-gl-sync-move";
|
|
3
10
|
import "./style.css";
|
|
11
|
+
// @ts-ignore
|
|
4
12
|
import { MapContext } from "@mapcomponents/react-core";
|
|
5
|
-
|
|
13
|
+
|
|
14
|
+
interface MlLayerSwipeProps {
|
|
15
|
+
/**
|
|
16
|
+
* Id of the first MapLibre instance.
|
|
17
|
+
*/
|
|
18
|
+
map1Id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Id of the second MapLibre instance.
|
|
21
|
+
*/
|
|
22
|
+
map2Id: string;
|
|
23
|
+
}
|
|
6
24
|
|
|
7
25
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @component
|
|
26
|
+
* creates a split view of 2 synchronised maplibre instances
|
|
11
27
|
*/
|
|
12
|
-
const MlLayerSwipe = (props) => {
|
|
13
|
-
const mapContext = useContext(MapContext);
|
|
28
|
+
const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
29
|
+
const mapContext: MapContextType = useContext(MapContext);
|
|
14
30
|
const initializedRef = useRef(false);
|
|
15
31
|
|
|
16
32
|
const [swipeX, setSwipeX] = useState(50);
|
|
17
|
-
const swipeXRef = useRef(
|
|
33
|
+
const swipeXRef = useRef(0);
|
|
18
34
|
|
|
19
35
|
const syncCleanupFunctionRef = useRef(null);
|
|
20
36
|
|
|
@@ -31,6 +47,7 @@ const MlLayerSwipe = (props) => {
|
|
|
31
47
|
|
|
32
48
|
const cleanup = () => {
|
|
33
49
|
if (syncCleanupFunctionRef.current) {
|
|
50
|
+
// @ts-ignore
|
|
34
51
|
syncCleanupFunctionRef.current();
|
|
35
52
|
}
|
|
36
53
|
};
|
|
@@ -39,7 +56,9 @@ const MlLayerSwipe = (props) => {
|
|
|
39
56
|
(e) => {
|
|
40
57
|
if (!mapExists()) return;
|
|
41
58
|
|
|
42
|
-
let bounds = mapContext.maps[props.map1Id]
|
|
59
|
+
let bounds = mapContext.maps[props.map1Id]
|
|
60
|
+
.getCanvas()
|
|
61
|
+
.getBoundingClientRect();
|
|
43
62
|
let clientX =
|
|
44
63
|
e.clientX ||
|
|
45
64
|
(typeof e.touches !== "undefined" && typeof e.touches[0] !== "undefined"
|
|
@@ -47,13 +66,17 @@ const MlLayerSwipe = (props) => {
|
|
|
47
66
|
: 0);
|
|
48
67
|
|
|
49
68
|
clientX -= bounds.x;
|
|
50
|
-
let swipeX_tmp = ((clientX / bounds.width) * 100).toFixed(2);
|
|
69
|
+
let swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
|
|
51
70
|
|
|
71
|
+
console.log(swipeX_tmp);
|
|
52
72
|
if (swipeXRef.current !== swipeX_tmp) {
|
|
53
73
|
setSwipeX(swipeX_tmp);
|
|
54
74
|
swipeXRef.current = swipeX_tmp;
|
|
55
75
|
|
|
56
|
-
var clipA =
|
|
76
|
+
var clipA =
|
|
77
|
+
"rect(0, " +
|
|
78
|
+
(swipeXRef.current * bounds.width) / 100 +
|
|
79
|
+
"px, 999em, 0)";
|
|
57
80
|
|
|
58
81
|
mapContext.maps[props.map2Id].getContainer().style.clip = clipA;
|
|
59
82
|
}
|
|
@@ -73,10 +96,12 @@ const MlLayerSwipe = (props) => {
|
|
|
73
96
|
mapContext.getMap(props.map1Id).map,
|
|
74
97
|
mapContext.getMap(props.map2Id).map
|
|
75
98
|
);
|
|
76
|
-
onMove({
|
|
99
|
+
onMove({
|
|
100
|
+
clientX: mapContext.maps[props.map1Id].getCanvas().clientWidth / 2,
|
|
101
|
+
});
|
|
77
102
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
78
103
|
|
|
79
|
-
const onDown = (e) => {
|
|
104
|
+
const onDown = (e: any) => {
|
|
80
105
|
if (e.touches) {
|
|
81
106
|
document.addEventListener("touchmove", onMove);
|
|
82
107
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -123,15 +148,4 @@ const MlLayerSwipe = (props) => {
|
|
|
123
148
|
);
|
|
124
149
|
};
|
|
125
150
|
|
|
126
|
-
MlLayerSwipe.propTypes = {
|
|
127
|
-
/**
|
|
128
|
-
* Id of the first MapLibre instance.
|
|
129
|
-
*/
|
|
130
|
-
map1Id: PropTypes.string,
|
|
131
|
-
/**
|
|
132
|
-
* Id of the second MapLibre instance.
|
|
133
|
-
*/
|
|
134
|
-
map2Id: PropTypes.string,
|
|
135
|
-
}
|
|
136
|
-
|
|
137
151
|
export default MlLayerSwipe;
|