react-spatial 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/conventional-pr-title.yml +21 -0
- package/.github/workflows/main.yml +28 -0
- package/.husky/commit-msg +4 -0
- package/.husky/post-checkout +4 -0
- package/.husky/post-merge +4 -0
- package/.husky/post-rebase +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.whitesource +8 -0
- package/CHANGELOG.md +65 -0
- package/DEVELOP.md +113 -0
- package/__mocks__/mapbox-gl.js +11 -0
- package/__mocks__/resize-observer-polyfill.js +9 -0
- package/babel.config.js +3 -0
- package/commitlint.config.js +1 -0
- package/data/topic1.js +119 -0
- package/data/topic2.js +28 -0
- package/doc/README.md +21 -0
- package/doc/doc-config.json +4 -0
- package/package.json +4 -3
- package/pull_request_template.md +16 -0
- package/renovate.json +4 -0
- package/scripts/read-pkg-json.js +17 -0
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +322 -0
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +69 -0
- package/src/components/BaseLayerSwitcher/README.md +61 -0
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +88 -0
- package/src/components/BaseLayerSwitcher/index.js +1 -0
- package/src/components/BasicMap/BasicMap.js +413 -0
- package/src/components/BasicMap/BasicMap.test.js +281 -0
- package/src/components/BasicMap/README.md +18 -0
- package/src/components/BasicMap/index.js +1 -0
- package/{components → src/components}/CanvasSaveButton/CanvasSaveButton.js +320 -93
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +148 -0
- package/src/components/CanvasSaveButton/README.md +76 -0
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +76 -0
- package/src/components/CanvasSaveButton/index.js +1 -0
- package/src/components/Copyright/Copyright.js +89 -0
- package/src/components/Copyright/Copyright.test.js +134 -0
- package/src/components/Copyright/README.md +36 -0
- package/src/components/Copyright/index.js +1 -0
- package/src/components/FeatureExportButton/FeatureExportButton.js +118 -0
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +417 -0
- package/src/components/FeatureExportButton/README.md +76 -0
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +67 -0
- package/src/components/FeatureExportButton/index.js +1 -0
- package/src/components/FitExtent/FitExtent.js +62 -0
- package/src/components/FitExtent/FitExtent.test.js +48 -0
- package/src/components/FitExtent/README.md +34 -0
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +13 -0
- package/src/components/FitExtent/index.js +1 -0
- package/{components → src/components}/Geolocation/Geolocation.js +144 -61
- package/src/components/Geolocation/Geolocation.test.js +267 -0
- package/src/components/Geolocation/README.md +25 -0
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +92 -0
- package/src/components/Geolocation/index.js +1 -0
- package/src/components/LayerTree/LayerTree.js +487 -0
- package/src/components/LayerTree/LayerTree.test.js +337 -0
- package/src/components/LayerTree/README.md +92 -0
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +1746 -0
- package/src/components/LayerTree/index.js +1 -0
- package/src/components/MousePosition/MousePosition.js +175 -0
- package/src/components/MousePosition/MousePosition.test.js +132 -0
- package/src/components/MousePosition/README.md +50 -0
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +76 -0
- package/src/components/MousePosition/index.js +1 -0
- package/src/components/NorthArrow/NorthArrow.js +75 -0
- package/src/components/NorthArrow/NorthArrow.test.js +104 -0
- package/src/components/NorthArrow/README.md +59 -0
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +117 -0
- package/src/components/NorthArrow/index.js +1 -0
- package/src/components/Overlay/Overlay.js +176 -0
- package/src/components/Overlay/Overlay.test.js +149 -0
- package/src/components/Overlay/README.md +59 -0
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +9 -0
- package/src/components/Overlay/index.js +1 -0
- package/src/components/Permalink/Permalink.js +326 -0
- package/src/components/Permalink/Permalink.test.js +285 -0
- package/src/components/Permalink/README.md +105 -0
- package/src/components/Permalink/index.js +1 -0
- package/{components → src/components}/Popup/Popup.js +165 -55
- package/src/components/Popup/Popup.test.js +307 -0
- package/src/components/Popup/README.md +93 -0
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +180 -0
- package/src/components/Popup/index.js +1 -0
- package/src/components/README.md +41 -0
- package/{components → src/components}/ResizeHandler/ResizeHandler.js +50 -15
- package/src/components/ResizeHandler/ResizeHandler.test.js +344 -0
- package/src/components/ResizeHandler/index.js +1 -0
- package/src/components/RouteSchedule/README.md +118 -0
- package/src/components/RouteSchedule/RouteSchedule.js +370 -0
- package/src/components/RouteSchedule/RouteSchedule.test.js +113 -0
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +248 -0
- package/src/components/RouteSchedule/index.js +1 -0
- package/src/components/ScaleLine/README.md +29 -0
- package/src/components/ScaleLine/ScaleLine.js +50 -0
- package/src/components/ScaleLine/ScaleLine.test.js +30 -0
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +7 -0
- package/src/components/ScaleLine/index.js +1 -0
- package/src/components/StopsFinder/README.md +50 -0
- package/src/components/StopsFinder/StopsFinder.js +284 -0
- package/src/components/StopsFinder/StopsFinder.test.js +17 -0
- package/src/components/StopsFinder/StopsFinderOption.js +61 -0
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +133 -0
- package/src/components/StopsFinder/index.js +1 -0
- package/src/components/Zoom/README.md +25 -0
- package/src/components/Zoom/Zoom.js +180 -0
- package/src/components/Zoom/Zoom.test.js +141 -0
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +201 -0
- package/src/components/Zoom/index.js +1 -0
- package/{propTypes.js → src/propTypes.js} +16 -12
- package/{setupTests.js → src/setupTests.js} +1 -1
- package/src/styleguidist/ComponentsList.js +52 -0
- package/src/styleguidist/StyleGuide.js +277 -0
- package/src/styleguidist/styleguidist.css +38 -0
- package/src/utils/GlobalsForOle.js +99 -0
- package/src/utils/KML.js +594 -0
- package/src/utils/KML.test.js +337 -0
- package/src/utils/KMLFormat.js +100 -0
- package/src/utils/KMLFormat.test.js +50 -0
- package/{utils → src/utils}/Styles.js +20 -14
- package/src/utils/__snapshots__/KML.test.js.snap.KML-readFeatures()-and-writeFeatures()-should-read-and-write-lineDash-and-fillPattern-style-for-polygon.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-3-(diagonal-line-from-bottom-left-tot-top-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-4-(diagonal-line-from-top-left-to-bottom-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/{utils → src/utils}/getPolygonPattern.js +34 -6
- package/src/utils/getPolygonPattern.test.js +61 -0
- package/src/utils/timeUtils.js +52 -0
- package/src/utils/timeUtils.test.js +30 -0
- package/styleguide.config.js +251 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -231
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +0 -7
- package/components/BaseLayerSwitcher/index.js +0 -1
- package/components/BaseLayerSwitcher/index.js.map +0 -7
- package/components/BasicMap/BasicMap.js +0 -278
- package/components/BasicMap/BasicMap.js.map +0 -7
- package/components/BasicMap/index.js +0 -1
- package/components/BasicMap/index.js.map +0 -7
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +0 -7
- package/components/CanvasSaveButton/index.js +0 -1
- package/components/CanvasSaveButton/index.js.map +0 -7
- package/components/Copyright/Copyright.js +0 -55
- package/components/Copyright/Copyright.js.map +0 -7
- package/components/Copyright/index.js +0 -1
- package/components/Copyright/index.js.map +0 -7
- package/components/FeatureExportButton/FeatureExportButton.js +0 -62
- package/components/FeatureExportButton/FeatureExportButton.js.map +0 -7
- package/components/FeatureExportButton/index.js +0 -1
- package/components/FeatureExportButton/index.js.map +0 -7
- package/components/FitExtent/FitExtent.js +0 -32
- package/components/FitExtent/FitExtent.js.map +0 -7
- package/components/FitExtent/index.js +0 -1
- package/components/FitExtent/index.js.map +0 -7
- package/components/Geolocation/Geolocation.js.map +0 -7
- package/components/Geolocation/index.js +0 -1
- package/components/Geolocation/index.js.map +0 -7
- package/components/LayerTree/LayerTree.js +0 -278
- package/components/LayerTree/LayerTree.js.map +0 -7
- package/components/LayerTree/index.js +0 -1
- package/components/LayerTree/index.js.map +0 -7
- package/components/MousePosition/MousePosition.js +0 -110
- package/components/MousePosition/MousePosition.js.map +0 -7
- package/components/MousePosition/index.js +0 -1
- package/components/MousePosition/index.js.map +0 -7
- package/components/NorthArrow/NorthArrow.js +0 -43
- package/components/NorthArrow/NorthArrow.js.map +0 -7
- package/components/NorthArrow/index.js +0 -1
- package/components/NorthArrow/index.js.map +0 -7
- package/components/Overlay/Overlay.js +0 -122
- package/components/Overlay/Overlay.js.map +0 -7
- package/components/Overlay/index.js +0 -1
- package/components/Overlay/index.js.map +0 -7
- package/components/Permalink/Permalink.js +0 -206
- package/components/Permalink/Permalink.js.map +0 -7
- package/components/Permalink/index.js +0 -1
- package/components/Permalink/index.js.map +0 -7
- package/components/Popup/Popup.js.map +0 -7
- package/components/Popup/index.js +0 -1
- package/components/Popup/index.js.map +0 -7
- package/components/ResizeHandler/ResizeHandler.js.map +0 -7
- package/components/ResizeHandler/index.js +0 -1
- package/components/ResizeHandler/index.js.map +0 -7
- package/components/RouteSchedule/RouteSchedule.js +0 -220
- package/components/RouteSchedule/RouteSchedule.js.map +0 -7
- package/components/RouteSchedule/index.js +0 -1
- package/components/RouteSchedule/index.js.map +0 -7
- package/components/ScaleLine/ScaleLine.js +0 -32
- package/components/ScaleLine/ScaleLine.js.map +0 -7
- package/components/ScaleLine/index.js +0 -1
- package/components/ScaleLine/index.js.map +0 -7
- package/components/StopsFinder/StopsFinder.js +0 -210
- package/components/StopsFinder/StopsFinder.js.map +0 -7
- package/components/StopsFinder/StopsFinderOption.js +0 -51
- package/components/StopsFinder/StopsFinderOption.js.map +0 -7
- package/components/StopsFinder/index.js +0 -1
- package/components/StopsFinder/index.js.map +0 -7
- package/components/Zoom/Zoom.js +0 -130
- package/components/Zoom/Zoom.js.map +0 -7
- package/components/Zoom/index.js +0 -1
- package/components/Zoom/index.js.map +0 -7
- package/propTypes.js.map +0 -7
- package/setupTests.js.map +0 -7
- package/utils/GlobalsForOle.js +0 -94
- package/utils/GlobalsForOle.js.map +0 -7
- package/utils/KML.js +0 -412
- package/utils/KML.js.map +0 -7
- package/utils/KMLFormat.js +0 -69
- package/utils/KMLFormat.js.map +0 -7
- package/utils/Styles.js.map +0 -7
- package/utils/getPolygonPattern.js.map +0 -7
- package/utils/timeUtils.js +0 -31
- package/utils/timeUtils.js.map +0 -7
- /package/{components → src/components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{components → src/components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{components → src/components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{components → src/components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{components → src/components}/Copyright/Copyright.md.scss +0 -0
- /package/{components → src/components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{components → src/components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{components → src/components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{components → src/components}/Geolocation/Geolocation.scss +0 -0
- /package/{components → src/components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{components → src/components}/LayerTree/LayerTree.scss +0 -0
- /package/{components → src/components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{components → src/components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{components → src/components}/Overlay/Overlay.md.scss +0 -0
- /package/{components → src/components}/Overlay/Overlay.scss +0 -0
- /package/{components → src/components}/Permalink/Permalink.md.scss +0 -0
- /package/{components → src/components}/Popup/Popup.md.scss +0 -0
- /package/{components → src/components}/Popup/Popup.scss +0 -0
- /package/{components → src/components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{components → src/components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{components → src/components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{components → src/components}/Zoom/Zoom.md.scss +0 -0
- /package/{components → src/components}/Zoom/Zoom.scss +0 -0
- /package/{images → src/images}/RouteSchedule/firstStation.png +0 -0
- /package/{images → src/images}/RouteSchedule/lastStation.png +0 -0
- /package/{images → src/images}/RouteSchedule/line.png +0 -0
- /package/{images → src/images}/RouteSchedule/station.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.basebright.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.osm.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.travic.png +0 -0
- /package/{images → src/images}/baselayer/open.topo.map.png +0 -0
- /package/{images → src/images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{images → src/images}/baselayer/osm.baselayer.png +0 -0
- /package/{images → src/images}/favicon.png +0 -0
- /package/{images → src/images}/geops_logo.png +0 -0
- /package/{images → src/images}/geops_logo.svg +0 -0
- /package/{images → src/images}/geops_qr.png +0 -0
- /package/{images → src/images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/bus_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/bus_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/rail_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/rail_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/subway_round blue-01.svg +0 -0
- /package/{images → src/images}/mots/subway_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/tram_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/tram_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_square-grey-01.svg +0 -0
- /package/{images → src/images}/northArrow.svg +0 -0
- /package/{images → src/images}/northArrow.url.svg +0 -0
- /package/{images → src/images}/northArrowCircle.svg +0 -0
- /package/{images → src/images}/northArrowCircle.url.svg +0 -0
- /package/{themes → src/themes}/README.md +0 -0
- /package/{themes → src/themes}/default/components.scss +0 -0
- /package/{themes → src/themes}/default/examples.scss +0 -0
- /package/{themes → src/themes}/default/index.scss +0 -0
- /package/{themes → src/themes}/default/mixins.scss +0 -0
- /package/{themes → src/themes}/default/variables.scss +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Geolocation/Geolocation.js"],
|
|
4
|
-
"sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport OLMap from 'ol/Map';\nimport { transform } from 'ol/proj';\nimport Point from 'ol/geom/Point';\nimport Feature from 'ol/Feature';\nimport { unByKey } from 'ol/Observable';\n\nimport Style from 'ol/style/Style';\nimport Circle from 'ol/style/Circle';\nimport Fill from 'ol/style/Fill';\nimport Stroke from 'ol/style/Stroke';\n\nimport VectorLayer from 'ol/layer/Vector';\nimport VectorSource from 'ol/source/Vector';\n\nimport { FaRegDotCircle } from 'react-icons/fa';\n\nconst propTypes = {\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * If true, the map will constantly recenter to the current Position\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\n};\n\nconst defaultProps = {\n className: 'rs-geolocation',\n children: <FaRegDotCircle focusable={false} />,\n onError: () => {},\n onSuccess: () => {},\n onActivate: () => {},\n onDeactivate: () => {},\n noCenterAfterDrag: false,\n alwaysRecenterToPosition: true,\n colorOrStyleFunc: [235, 0, 0],\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = 'geolocation' in navigator;\n\n if (!geolocation) {\n onError();\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n error() {\n const { onError } = this.props;\n\n this.deactivate();\n onError();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on('pointerdrag', () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n update({ coords: { latitude, longitude } }) {\n const { map, alwaysRecenterToPosition, onSuccess } = this.props;\n\n const position = transform(\n [longitude, latitude],\n 'EPSG:4326',\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n radius: 20,\n rotation,\n fill: new Fill({\n color: 'rgba(255, 255, 255, 0.01)',\n }),\n stroke: new Stroke({\n lineDash: [30, 10],\n width: 6,\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n radius: 10,\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n role=\"button\"\n tabIndex=\"0\"\n className={`${className} ${active ? 'rs-active' : ''}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AAEtB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAClB,OAAO,aAAa;AACpB,SAAS,eAAe;AAExB,OAAO,WAAW;AAClB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AAEnB,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AAEzB,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA,EAIhB,WAAW,UAAU;AAAA,EAKrB,UAAU,UAAU;AAAA,EAKpB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,SAAS,UAAU;AAAA,EAKnB,WAAW,UAAU;AAAA,EAKrB,YAAY,UAAU;AAAA,EAKtB,cAAc,UAAU;AAAA,EAKxB,mBAAmB,UAAU;AAAA,EAK7B,0BAA0B,UAAU;AAAA,EAMpC,kBAAkB,UAAU,UAAU;AAAA,IACpC,UAAU,QAAQ,UAAU,MAAM;AAAA,IAClC,UAAU;AAAA,EACZ,CAAC;AACH;AAEA,MAAM,eAAe;AAAA,EACnB,WAAW;AAAA,EACX,UAAU,oCAAC;AAAA,IAAe,WAAW;AAAA,GAAO;AAAA,EAC5C,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,mBAAmB;AAAA,EACnB,0BAA0B;AAAA,EAC1B,kBAAkB,CAAC,KAAK,GAAG,CAAC;AAC9B;AAMA,MAAM,oBAAoB,cAAc;AAAA,EACtC,YAAY,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AAC,MAAM;AACjB,eAAO,EAAE,UAAU,MAAM,KAAK,OAAO;AAAA,MACvC;AAAA,MAEC,GAAG;AAAA,OAEH,QACH;AAAA,EAEJ;AACF;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAE3B,eAAe;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./Geolocation";
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { Layer, getLayersAsFlatArray } from "mobility-toolbox-js/ol";
|
|
4
|
-
import { unByKey } from "ol/Observable";
|
|
5
|
-
const propTypes = {
|
|
6
|
-
layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
|
|
7
|
-
className: PropTypes.string,
|
|
8
|
-
padding: PropTypes.number,
|
|
9
|
-
isItemHidden: PropTypes.func,
|
|
10
|
-
getParentClassName: PropTypes.func,
|
|
11
|
-
renderItem: PropTypes.func,
|
|
12
|
-
renderItemContent: PropTypes.func,
|
|
13
|
-
renderBeforeItem: PropTypes.func,
|
|
14
|
-
renderAfterItem: PropTypes.func,
|
|
15
|
-
renderLabel: PropTypes.func,
|
|
16
|
-
titles: PropTypes.shape({
|
|
17
|
-
layerShow: PropTypes.string,
|
|
18
|
-
layerHide: PropTypes.string,
|
|
19
|
-
subLayerShow: PropTypes.string,
|
|
20
|
-
subLayerHide: PropTypes.string
|
|
21
|
-
}),
|
|
22
|
-
expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
23
|
-
t: PropTypes.func
|
|
24
|
-
};
|
|
25
|
-
const defaultProps = {
|
|
26
|
-
layers: [],
|
|
27
|
-
className: "rs-layer-tree",
|
|
28
|
-
padding: 30,
|
|
29
|
-
isItemHidden: () => {
|
|
30
|
-
return false;
|
|
31
|
-
},
|
|
32
|
-
getParentClassName: () => {
|
|
33
|
-
return void 0;
|
|
34
|
-
},
|
|
35
|
-
renderItem: null,
|
|
36
|
-
renderItemContent: null,
|
|
37
|
-
renderBeforeItem: null,
|
|
38
|
-
renderAfterItem: null,
|
|
39
|
-
renderLabel: (layer, layerComp) => {
|
|
40
|
-
const { t } = layerComp.props;
|
|
41
|
-
return t(layer.name);
|
|
42
|
-
},
|
|
43
|
-
titles: {
|
|
44
|
-
layerShow: "Show layer",
|
|
45
|
-
layerHide: "Hide layer",
|
|
46
|
-
subLayerShow: "Show sublayer",
|
|
47
|
-
subLayerHide: "Hide sublayer"
|
|
48
|
-
},
|
|
49
|
-
t: (s) => {
|
|
50
|
-
return s;
|
|
51
|
-
},
|
|
52
|
-
expandChildren: false
|
|
53
|
-
};
|
|
54
|
-
class LayerTree extends Component {
|
|
55
|
-
constructor(props) {
|
|
56
|
-
super(props);
|
|
57
|
-
const { layers, isItemHidden } = this.props;
|
|
58
|
-
const initialExpandedLayers = layers ? this.getExpandedLayers(
|
|
59
|
-
layers.filter((l) => {
|
|
60
|
-
return !isItemHidden(l) && (l.children || []).filter((child) => {
|
|
61
|
-
return child.visible;
|
|
62
|
-
}).filter((c) => {
|
|
63
|
-
return !isItemHidden(c);
|
|
64
|
-
}).length;
|
|
65
|
-
})
|
|
66
|
-
) : [];
|
|
67
|
-
this.state = {
|
|
68
|
-
rootLayer: new Layer(),
|
|
69
|
-
expandedLayers: initialExpandedLayers,
|
|
70
|
-
revision: 0
|
|
71
|
-
};
|
|
72
|
-
this.olKeys = [];
|
|
73
|
-
}
|
|
74
|
-
componentDidMount() {
|
|
75
|
-
this.updateLayers();
|
|
76
|
-
}
|
|
77
|
-
componentDidUpdate(prevProps) {
|
|
78
|
-
const { layers } = this.props;
|
|
79
|
-
if (layers !== prevProps.layers) {
|
|
80
|
-
this.updateLayers();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
componentWillUnmount() {
|
|
84
|
-
unByKey(this.olKeys);
|
|
85
|
-
this.olKeys = [];
|
|
86
|
-
}
|
|
87
|
-
onInputClick(layer, toggle = false) {
|
|
88
|
-
if (toggle) {
|
|
89
|
-
this.onToggle(layer);
|
|
90
|
-
} else if (layer.setVisible) {
|
|
91
|
-
layer.setVisible(!layer.visible);
|
|
92
|
-
} else {
|
|
93
|
-
layer.visible = !layer.visible;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
onToggle(layer) {
|
|
97
|
-
const { expandedLayers } = this.state;
|
|
98
|
-
const pos = expandedLayers.indexOf(layer);
|
|
99
|
-
if (pos > -1) {
|
|
100
|
-
expandedLayers.splice(pos, 1);
|
|
101
|
-
} else {
|
|
102
|
-
expandedLayers.push(...this.getExpandedLayers([layer]));
|
|
103
|
-
}
|
|
104
|
-
this.setState({ expandedLayers });
|
|
105
|
-
}
|
|
106
|
-
getExpandedLayers(layers) {
|
|
107
|
-
const { isItemHidden } = this.props;
|
|
108
|
-
const children = layers.flatMap((l) => {
|
|
109
|
-
return l.children.filter((c) => {
|
|
110
|
-
return !isItemHidden(c) && c.get("isAlwaysExpanded");
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
if (!children.length) {
|
|
114
|
-
return layers;
|
|
115
|
-
}
|
|
116
|
-
return [...layers, this.getExpandedLayers(children)].flat();
|
|
117
|
-
}
|
|
118
|
-
updateLayers() {
|
|
119
|
-
const { layers, expandChildren } = this.props;
|
|
120
|
-
let rootLayer = new Layer();
|
|
121
|
-
if (Array.isArray(layers)) {
|
|
122
|
-
if (layers.length === 1) {
|
|
123
|
-
[rootLayer] = layers;
|
|
124
|
-
}
|
|
125
|
-
rootLayer = new Layer({ children: layers });
|
|
126
|
-
} else {
|
|
127
|
-
rootLayer = layers;
|
|
128
|
-
}
|
|
129
|
-
getLayersAsFlatArray(rootLayer).forEach((layer) => {
|
|
130
|
-
this.olKeys.push(
|
|
131
|
-
layer.on("propertychange", () => {
|
|
132
|
-
const { revision } = this.state;
|
|
133
|
-
this.setState({ revision: revision + 1 });
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
const state = { rootLayer };
|
|
138
|
-
if (typeof expandChildren === "function" ? expandChildren(layers) : expandChildren) {
|
|
139
|
-
state.expandedLayers = rootLayer.children.flatMap((l) => {
|
|
140
|
-
return this.expandLayer(l);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
this.setState(state);
|
|
144
|
-
}
|
|
145
|
-
expandLayer(layer, expLayers = []) {
|
|
146
|
-
const { isItemHidden } = this.props;
|
|
147
|
-
if (layer.visible && !isItemHidden(layer)) {
|
|
148
|
-
const children = layer.children.filter((c) => {
|
|
149
|
-
return !isItemHidden(c) && !c.get("isAlwaysExpanded");
|
|
150
|
-
}).flatMap((c) => {
|
|
151
|
-
return this.expandLayer(c, expLayers);
|
|
152
|
-
});
|
|
153
|
-
return [...expLayers, ...children, layer];
|
|
154
|
-
}
|
|
155
|
-
return expLayers;
|
|
156
|
-
}
|
|
157
|
-
renderInput(layer, inputProps) {
|
|
158
|
-
const { titles, isItemHidden } = this.props;
|
|
159
|
-
let tabIndex = 0;
|
|
160
|
-
if (!(layer.children || []).filter((c) => {
|
|
161
|
-
return !isItemHidden(c);
|
|
162
|
-
}).length) {
|
|
163
|
-
tabIndex = -1;
|
|
164
|
-
}
|
|
165
|
-
const inputType = layer.get("group") ? "radio" : "checkbox";
|
|
166
|
-
return /* @__PURE__ */ React.createElement("label", {
|
|
167
|
-
className: `rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`,
|
|
168
|
-
tabIndex,
|
|
169
|
-
title: layer.visible ? titles.layerHide : titles.layerShow,
|
|
170
|
-
"aria-label": layer.visible ? titles.layerHide : titles.layerShow,
|
|
171
|
-
onKeyPress: (e) => {
|
|
172
|
-
if (e.which === 13) {
|
|
173
|
-
this.onInputClick(layer);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}, /* @__PURE__ */ React.createElement("input", {
|
|
177
|
-
type: inputType,
|
|
178
|
-
tabIndex: -1,
|
|
179
|
-
checked: layer.visible,
|
|
180
|
-
readOnly: true,
|
|
181
|
-
onClick: () => {
|
|
182
|
-
return this.onInputClick(layer);
|
|
183
|
-
},
|
|
184
|
-
...inputProps
|
|
185
|
-
}), /* @__PURE__ */ React.createElement("span", null));
|
|
186
|
-
}
|
|
187
|
-
renderArrow(layer) {
|
|
188
|
-
const { isItemHidden } = this.props;
|
|
189
|
-
const { expandedLayers } = this.state;
|
|
190
|
-
if (!(layer.children || []).filter((c) => {
|
|
191
|
-
return !isItemHidden(c);
|
|
192
|
-
}).length || layer.get("isAlwaysExpanded")) {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
196
|
-
className: `rs-layer-tree-arrow rs-layer-tree-arrow-${!expandedLayers.includes(layer) ? "collapsed" : "expanded"}`
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
renderToggleButton(layer, toggleProps) {
|
|
200
|
-
const { t, titles, isItemHidden, renderLabel } = this.props;
|
|
201
|
-
const { expandedLayers } = this.state;
|
|
202
|
-
const onInputClick = () => {
|
|
203
|
-
this.onInputClick(
|
|
204
|
-
layer,
|
|
205
|
-
(layer.children || []).filter((c) => {
|
|
206
|
-
return !isItemHidden(c);
|
|
207
|
-
}).length && !layer.get("isAlwaysExpanded")
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
const title = `${t(layer.name)} ${expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow}`;
|
|
211
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
212
|
-
role: "button",
|
|
213
|
-
tabIndex: 0,
|
|
214
|
-
className: "rs-layer-tree-toggle",
|
|
215
|
-
title,
|
|
216
|
-
"aria-expanded": expandedLayers.includes(layer),
|
|
217
|
-
"aria-label": title,
|
|
218
|
-
onClick: onInputClick,
|
|
219
|
-
onKeyPress: onInputClick,
|
|
220
|
-
...toggleProps
|
|
221
|
-
}, /* @__PURE__ */ React.createElement("div", null, renderLabel(layer, this)), this.renderArrow(layer));
|
|
222
|
-
}
|
|
223
|
-
renderItemContent(layer, inputProps = {}, toggleProps = {}) {
|
|
224
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, this.renderInput(layer, inputProps), this.renderToggleButton(layer, toggleProps));
|
|
225
|
-
}
|
|
226
|
-
renderItem(layer, level) {
|
|
227
|
-
const { isItemHidden } = this.props;
|
|
228
|
-
const { expandedLayers } = this.state;
|
|
229
|
-
const {
|
|
230
|
-
renderItem,
|
|
231
|
-
renderItemContent,
|
|
232
|
-
renderBeforeItem,
|
|
233
|
-
renderAfterItem,
|
|
234
|
-
padding,
|
|
235
|
-
getParentClassName
|
|
236
|
-
} = this.props;
|
|
237
|
-
const children = expandedLayers.includes(layer) ? [
|
|
238
|
-
...(layer.children || []).filter((c) => {
|
|
239
|
-
return !isItemHidden(c);
|
|
240
|
-
})
|
|
241
|
-
] : [];
|
|
242
|
-
if (renderItem) {
|
|
243
|
-
return renderItem(layer, this.onInputClick, this.onToggle);
|
|
244
|
-
}
|
|
245
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
246
|
-
className: getParentClassName(),
|
|
247
|
-
key: layer.key
|
|
248
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
249
|
-
className: `rs-layer-tree-item ${layer.visible ? "rs-visible" : ""}`,
|
|
250
|
-
style: {
|
|
251
|
-
paddingLeft: `${padding * level}px`
|
|
252
|
-
}
|
|
253
|
-
}, renderItemContent ? renderItemContent(layer, this) : this.renderItemContent(layer)), renderBeforeItem && renderBeforeItem(layer, level, this), [...children].reverse().map((child) => {
|
|
254
|
-
return this.renderItem(child, level + 1);
|
|
255
|
-
}), renderAfterItem && renderAfterItem(layer, level, this));
|
|
256
|
-
}
|
|
257
|
-
renderTree() {
|
|
258
|
-
const { isItemHidden } = this.props;
|
|
259
|
-
const { rootLayer } = this.state;
|
|
260
|
-
if (!rootLayer?.children?.length) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, rootLayer.children.filter((l) => {
|
|
264
|
-
return !isItemHidden(l);
|
|
265
|
-
}).reverse().map((l) => {
|
|
266
|
-
return this.renderItem(l, 0);
|
|
267
|
-
}));
|
|
268
|
-
}
|
|
269
|
-
render() {
|
|
270
|
-
const { className } = this.props;
|
|
271
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
272
|
-
className
|
|
273
|
-
}, this.renderTree());
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
LayerTree.propTypes = propTypes;
|
|
277
|
-
LayerTree.defaultProps = defaultProps;
|
|
278
|
-
export default LayerTree;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/LayerTree/LayerTree.js"],
|
|
4
|
-
"sourcesContent": ["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, getLayersAsFlatArray } from 'mobility-toolbox-js/ol';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: 'rs-layer-tree',\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: 'Show layer',\n layerHide: 'Hide layer',\n subLayerShow: 'Show sublayer',\n subLayerHide: 'Hide sublayer',\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return l.children.filter((c) => {\n return !isItemHidden(c) && c.get('isAlwaysExpanded');\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayers() {\n const { layers, expandChildren } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer();\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on('propertychange', () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === 'function'\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\n .filter((c) => {\n return !isItemHidden(c) && !c.get('isAlwaysExpanded');\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer, inputProps) {\n const { titles, isItemHidden } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get('group') ? 'radio' : 'checkbox';\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get('isAlwaysExpanded')\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? 'collapsed' : 'expanded'\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get('isAlwaysExpanded'),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? 'rs-visible' : ''}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,4BAA4B;AAC5C,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA,EAIhB,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA,EAKrD,WAAW,UAAU;AAAA,EAKrB,SAAS,UAAU;AAAA,EASnB,cAAc,UAAU;AAAA,EAKxB,oBAAoB,UAAU;AAAA,EAS9B,YAAY,UAAU;AAAA,EAYtB,mBAAmB,UAAU;AAAA,EAS7B,kBAAkB,UAAU;AAAA,EAS5B,iBAAiB,UAAU;AAAA,EAU3B,aAAa,UAAU;AAAA,EAKvB,QAAQ,UAAU,MAAM;AAAA,IAItB,WAAW,UAAU;AAAA,IAIrB,WAAW,UAAU;AAAA,IAIrB,cAAc,UAAU;AAAA,IAIxB,cAAc,UAAU;AAAA,EAC1B,CAAC;AAAA,EAOD,gBAAgB,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,IAAI,CAAC;AAAA,EAMpE,GAAG,UAAU;AACf;AAEA,MAAM,eAAe;AAAA,EACnB,QAAQ,CAAC;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,cAAc,MAAM;AAClB,WAAO;AAAA,EACT;AAAA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IACzC,CAAC,GACA,mBAAmB,gBAAgB,OAAO,OAAO,IAAI,CACxD;AAAA,EAEJ;AAAA,EAEA,aAAa;AACX,UAAM,EAAE,aAAa,IAAI,KAAK;AAC9B,UAAM,EAAE,UAAU,IAAI,KAAK;AAE3B,QAAI,CAAC,WAAW,UAAU,QAAQ;AAChC,aAAO;AAAA,IACT;AAEA,WACE,0DACG,UAAU,SACR,OAAO,CAAC,MAAM;AACb,aAAO,CAAC,aAAa,CAAC;AAAA,IACxB,CAAC,EACA,QAAQ,EACR,IAAI,CAAC,MAAM;AACV,aAAO,KAAK,WAAW,GAAG,CAAC;AAAA,IAC7B,CAAC,CACL;AAAA,EAEJ;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,oCAAC;AAAA,MAAI;AAAA,OAAuB,KAAK,WAAW,CAAE;AAAA,EACvD;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./LayerTree";
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import OLMap from "ol/Map";
|
|
4
|
-
import { createStringXY } from "ol/coordinate";
|
|
5
|
-
import OLMousePosition from "ol/control/MousePosition";
|
|
6
|
-
const propTypes = {
|
|
7
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
8
|
-
projections: PropTypes.arrayOf(
|
|
9
|
-
PropTypes.shape({
|
|
10
|
-
label: PropTypes.string.isRequired,
|
|
11
|
-
value: PropTypes.string.isRequired,
|
|
12
|
-
format: PropTypes.func
|
|
13
|
-
})
|
|
14
|
-
),
|
|
15
|
-
projectionValue: PropTypes.shape({
|
|
16
|
-
label: PropTypes.string.isRequired,
|
|
17
|
-
value: PropTypes.string.isRequired,
|
|
18
|
-
format: PropTypes.func
|
|
19
|
-
}),
|
|
20
|
-
onChange: PropTypes.func
|
|
21
|
-
};
|
|
22
|
-
const defaultProps = {
|
|
23
|
-
onChange: () => {
|
|
24
|
-
},
|
|
25
|
-
projections: [
|
|
26
|
-
{
|
|
27
|
-
label: "EPSG:4326",
|
|
28
|
-
value: "EPSG:4326"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: "EPSG:3857",
|
|
32
|
-
value: "EPSG:3857"
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
projectionValue: null
|
|
36
|
-
};
|
|
37
|
-
function MousePosition({
|
|
38
|
-
map,
|
|
39
|
-
projections,
|
|
40
|
-
projectionValue,
|
|
41
|
-
onChange,
|
|
42
|
-
...other
|
|
43
|
-
}) {
|
|
44
|
-
const [projection, setProjection] = useState(
|
|
45
|
-
projections && (projectionValue && projections.find((p) => {
|
|
46
|
-
return p.value === projectionValue.value;
|
|
47
|
-
}) || projections[0])
|
|
48
|
-
);
|
|
49
|
-
const [control, setControl] = useState();
|
|
50
|
-
const ref = useRef();
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const mousePosition = new OLMousePosition({
|
|
53
|
-
target: ref.current,
|
|
54
|
-
undefinedHTML: " ",
|
|
55
|
-
className: ""
|
|
56
|
-
});
|
|
57
|
-
map.addControl(mousePosition);
|
|
58
|
-
setControl(mousePosition);
|
|
59
|
-
return () => {
|
|
60
|
-
map.removeControl(mousePosition);
|
|
61
|
-
};
|
|
62
|
-
}, [map]);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!projection || !control) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
control.setProjection(projection.value);
|
|
68
|
-
control.setCoordinateFormat(projection.format || createStringXY(4));
|
|
69
|
-
}, [projection, control]);
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (projections) {
|
|
72
|
-
const proj = projectionValue && projections.find((p) => {
|
|
73
|
-
return p.value === projectionValue.value;
|
|
74
|
-
}) || projections[0];
|
|
75
|
-
setProjection(proj);
|
|
76
|
-
}
|
|
77
|
-
}, [projections, projectionValue]);
|
|
78
|
-
const onChangeCb = useCallback(
|
|
79
|
-
(evt) => {
|
|
80
|
-
const newProj = projections.find((opt) => {
|
|
81
|
-
return evt.target.value === opt.value;
|
|
82
|
-
});
|
|
83
|
-
setProjection(newProj);
|
|
84
|
-
onChange(evt, newProj);
|
|
85
|
-
},
|
|
86
|
-
[onChange, projections]
|
|
87
|
-
);
|
|
88
|
-
if (!projection || !projections || !projections.length) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
92
|
-
className: "rs-mouse-position",
|
|
93
|
-
...other
|
|
94
|
-
}, /* @__PURE__ */ React.createElement("select", {
|
|
95
|
-
className: "rs-select",
|
|
96
|
-
value: projection.value,
|
|
97
|
-
onChange: onChangeCb
|
|
98
|
-
}, projections.map((option) => {
|
|
99
|
-
return /* @__PURE__ */ React.createElement("option", {
|
|
100
|
-
key: option.value,
|
|
101
|
-
value: option.value
|
|
102
|
-
}, option.label);
|
|
103
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
104
|
-
ref,
|
|
105
|
-
className: "rs-coordinates"
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
MousePosition.propTypes = propTypes;
|
|
109
|
-
MousePosition.defaultProps = defaultProps;
|
|
110
|
-
export default React.memo(MousePosition);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/MousePosition/MousePosition.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { createStringXY } from 'ol/coordinate';\nimport OLMousePosition from 'ol/control/MousePosition';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: 'EPSG:4326',\n value: 'EPSG:4326',\n },\n {\n label: 'EPSG:3857',\n value: 'EPSG:3857',\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n undefinedHTML: ' ',\n className: '',\n });\n map.addControl(mousePosition);\n setControl(mousePosition);\n\n return () => {\n map.removeControl(mousePosition);\n };\n }, [map]);\n\n useEffect(() => {\n if (!projection || !control) {\n return;\n }\n control.setProjection(projection.value);\n control.setCoordinateFormat(projection.format || createStringXY(4));\n }, [projection, control]);\n\n useEffect(() => {\n if (projections) {\n const proj =\n (projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0];\n setProjection(proj);\n }\n }, [projections, projectionValue]);\n\n const onChangeCb = useCallback(\n (evt) => {\n const newProj = projections.find((opt) => {\n return evt.target.value === opt.value;\n });\n setProjection(newProj);\n onChange(evt, newProj);\n },\n [onChange, projections],\n );\n\n if (!projection || !projections || !projections.length) {\n return null;\n }\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-mouse-position\" {...other}>\n <select\n className=\"rs-select\"\n value={projection.value}\n onChange={onChangeCb}\n >\n {projections.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </select>\n <span ref={ref} className=\"rs-coordinates\" />\n </div>\n );\n}\n\nMousePosition.propTypes = propTypes;\nMousePosition.defaultProps = defaultProps;\n\nexport default React.memo(MousePosition);\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,UAAU,QAAQ,WAAW,mBAAmB;AAChE,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAC/B,OAAO,qBAAqB;AAE5B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,aAAa,UAAU;AAAA,IACrB,UAAU,MAAM;AAAA,MAId,OAAO,UAAU,OAAO;AAAA,MAMxB,OAAO,UAAU,OAAO;AAAA,MAKxB,QAAQ,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAKA,iBAAiB,UAAU,MAAM;AAAA,IAI/B,OAAO,UAAU,OAAO;AAAA,IAMxB,OAAO,UAAU,OAAO;AAAA,IAKxB,QAAQ,UAAU;AAAA,EACpB,CAAC;AAAA,EAOD,UAAU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jB,CAAC,QAAQ;AACP,YAAM,UAAU,YAAY,KAAK,CAAC,QAAQ;AACxC,eAAO,IAAI,OAAO,UAAU,IAAI;AAAA,MAClC,CAAC;AACD,oBAAc,OAAO;AACrB,eAAS,KAAK,OAAO;AAAA,IACvB;AAAA,IACA,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,MAAI,CAAC,cAAc,CAAC,eAAe,CAAC,YAAY,QAAQ;AACtD,WAAO;AAAA,EACT;AAEA,SAEE,oCAAC;AAAA,IAAI,WAAU;AAAA,IAAqB,GAAG;AAAA,KACrC,oCAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO,WAAW;AAAA,IAClB,UAAU;AAAA,KAET,YAAY,IAAI,CAAC,WAAW;AAC3B,WACE,oCAAC;AAAA,MAAO,KAAK,OAAO;AAAA,MAAO,OAAO,OAAO;AAAA,OACtC,OAAO,KACV;AAAA,EAEJ,CAAC,CACH,GACA,oCAAC;AAAA,IAAK;AAAA,IAAU,WAAU;AAAA,GAAiB,CAC7C;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./MousePosition";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import OLMap from "ol/Map";
|
|
4
|
-
import { unByKey } from "ol/Observable";
|
|
5
|
-
import { toDegrees } from "ol/math";
|
|
6
|
-
import NorthArrowSimple from "../../images/northArrow.svg";
|
|
7
|
-
import NorthArrowCircle from "../../images/northArrowCircle.svg";
|
|
8
|
-
const propTypes = {
|
|
9
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
10
|
-
rotationOffset: PropTypes.number,
|
|
11
|
-
circled: PropTypes.bool,
|
|
12
|
-
children: PropTypes.node
|
|
13
|
-
};
|
|
14
|
-
const defaultProps = {
|
|
15
|
-
rotationOffset: 0,
|
|
16
|
-
circled: false,
|
|
17
|
-
children: null
|
|
18
|
-
};
|
|
19
|
-
const getRotation = (map, rotationOffset) => {
|
|
20
|
-
return toDegrees(map.getView().getRotation()) + rotationOffset;
|
|
21
|
-
};
|
|
22
|
-
function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
|
|
23
|
-
const [rotation, setRotation] = useState(rotationOffset);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!map) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const key = map.on("postrender", () => {
|
|
29
|
-
setRotation(getRotation(map, rotationOffset));
|
|
30
|
-
});
|
|
31
|
-
return () => {
|
|
32
|
-
unByKey(key);
|
|
33
|
-
};
|
|
34
|
-
}, [map, rotationOffset]);
|
|
35
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
36
|
-
className: "rs-north-arrow",
|
|
37
|
-
...other,
|
|
38
|
-
style: { transform: `rotate(${rotation}deg)` }
|
|
39
|
-
}, children || (circled ? /* @__PURE__ */ React.createElement(NorthArrowCircle, null) : /* @__PURE__ */ React.createElement(NorthArrowSimple, null)));
|
|
40
|
-
}
|
|
41
|
-
NorthArrow.propTypes = propTypes;
|
|
42
|
-
NorthArrow.defaultProps = defaultProps;
|
|
43
|
-
export default React.memo(NorthArrow);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport { toDegrees } from 'ol/math';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return toDegrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,gBAAgB,UAAU;AAAA,EAK1B,SAAS,UAAU;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,UAAU,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAClD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,aAAa,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE,oCAAC;AAAA,IACC,WAAU;AAAA,IAET,GAAG;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,eAAe;AAAA,KAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./NorthArrow";
|