react-spatial 1.5.3 → 1.5.5
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/components/BaseLayerSwitcher/BaseLayerSwitcher.js +262 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
- package/components/BaseLayerSwitcher/index.js +1 -0
- package/components/BaseLayerSwitcher/index.js.map +7 -0
- package/{src/components → components}/BasicMap/BasicMap.js +80 -170
- package/components/BasicMap/BasicMap.js.map +7 -0
- package/components/BasicMap/index.js +1 -0
- package/components/BasicMap/index.js.map +7 -0
- package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +133 -278
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
- package/components/CanvasSaveButton/index.js +1 -0
- package/components/CanvasSaveButton/index.js.map +7 -0
- package/{src/components → components}/Copyright/Copyright.js +21 -41
- package/components/Copyright/Copyright.js.map +7 -0
- package/components/Copyright/index.js +1 -0
- package/components/Copyright/index.js.map +7 -0
- package/components/FeatureExportButton/FeatureExportButton.js +80 -0
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
- package/components/FeatureExportButton/index.js +1 -0
- package/components/FeatureExportButton/index.js.map +7 -0
- package/{src/components → components}/FitExtent/FitExtent.js +16 -30
- package/components/FitExtent/FitExtent.js.map +7 -0
- package/components/FitExtent/index.js +1 -0
- package/components/FitExtent/index.js.map +7 -0
- package/{src/components → components}/Geolocation/Geolocation.js +60 -110
- package/components/Geolocation/Geolocation.js.map +7 -0
- package/components/Geolocation/index.js +1 -0
- package/components/Geolocation/index.js.map +7 -0
- package/{src/components → components}/LayerTree/LayerTree.js +113 -213
- package/components/LayerTree/LayerTree.js.map +7 -0
- package/components/LayerTree/index.js +1 -0
- package/components/LayerTree/index.js.map +7 -0
- package/{src/components → components}/MousePosition/MousePosition.js +37 -70
- package/components/MousePosition/MousePosition.js.map +7 -0
- package/components/MousePosition/index.js +1 -0
- package/components/MousePosition/index.js.map +7 -0
- package/{src/components → components}/NorthArrow/NorthArrow.js +18 -34
- package/components/NorthArrow/NorthArrow.js.map +7 -0
- package/components/NorthArrow/index.js +1 -0
- package/components/NorthArrow/index.js.map +7 -0
- package/{src/components → components}/Overlay/Overlay.js +59 -85
- package/components/Overlay/Overlay.js.map +7 -0
- package/components/Overlay/index.js +1 -0
- package/components/Overlay/index.js.map +7 -0
- package/{src/components → components}/Permalink/Permalink.js +64 -147
- package/components/Permalink/Permalink.js.map +7 -0
- package/components/Permalink/index.js +1 -0
- package/components/Permalink/index.js.map +7 -0
- package/{src/components → components}/Popup/Popup.js +57 -116
- package/components/Popup/Popup.js.map +7 -0
- package/components/Popup/index.js +1 -0
- package/components/Popup/index.js.map +7 -0
- package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -49
- package/components/ResizeHandler/ResizeHandler.js.map +7 -0
- package/components/ResizeHandler/index.js +1 -0
- package/components/ResizeHandler/index.js.map +7 -0
- package/components/RouteSchedule/RouteSchedule.js +268 -0
- package/components/RouteSchedule/RouteSchedule.js.map +7 -0
- package/components/RouteSchedule/index.js +1 -0
- package/components/RouteSchedule/index.js.map +7 -0
- package/{src/components → components}/ScaleLine/ScaleLine.js +8 -23
- package/components/ScaleLine/ScaleLine.js.map +7 -0
- package/components/ScaleLine/index.js +1 -0
- package/components/ScaleLine/index.js.map +7 -0
- package/{src/components → components}/StopsFinder/StopsFinder.js +74 -103
- package/components/StopsFinder/StopsFinder.js.map +7 -0
- package/components/StopsFinder/StopsFinderOption.js +44 -0
- package/components/StopsFinder/StopsFinderOption.js.map +7 -0
- package/components/StopsFinder/index.js +1 -0
- package/components/StopsFinder/index.js.map +7 -0
- package/{src/components → components}/Zoom/Zoom.js +46 -77
- package/components/Zoom/Zoom.js.map +7 -0
- package/components/Zoom/index.js +1 -0
- package/components/Zoom/index.js.map +7 -0
- package/package.json +32 -31
- package/{src/propTypes.js → propTypes.js} +30 -16
- package/propTypes.js.map +7 -0
- package/{src/setupTests.js → setupTests.js} +1 -1
- package/setupTests.js.map +7 -0
- package/utils/GlobalsForOle.js +94 -0
- package/utils/GlobalsForOle.js.map +7 -0
- package/utils/KML.js +420 -0
- package/utils/KML.js.map +7 -0
- package/{src/utils → utils}/KMLFormat.js +29 -32
- package/utils/KMLFormat.js.map +7 -0
- package/{src/utils → utils}/Styles.js +14 -20
- package/utils/Styles.js.map +7 -0
- package/{src/utils → utils}/getPolygonPattern.js +6 -34
- package/utils/getPolygonPattern.js.map +7 -0
- package/{src/utils → utils}/timeUtils.js +5 -22
- package/utils/timeUtils.js.map +7 -0
- package/.github/workflows/conventional-pr-title.yml +0 -21
- package/.github/workflows/main.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.whitesource +0 -8
- package/CHANGELOG.md +0 -65
- package/DEVELOP.md +0 -113
- package/__mocks__/mapbox-gl.js +0 -11
- package/__mocks__/resize-observer-polyfill.js +0 -9
- package/babel.config.js +0 -3
- package/commitlint.config.js +0 -1
- package/data/topic1.js +0 -119
- package/data/topic2.js +0 -28
- package/doc/README.md +0 -21
- package/doc/doc-config.json +0 -4
- package/pull_request_template.md +0 -16
- package/renovate.json +0 -4
- package/scripts/read-pkg-json.js +0 -17
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
- package/src/components/BaseLayerSwitcher/README.md +0 -61
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
- package/src/components/BaseLayerSwitcher/index.js +0 -1
- package/src/components/BasicMap/BasicMap.test.js +0 -281
- package/src/components/BasicMap/README.md +0 -18
- package/src/components/BasicMap/index.js +0 -1
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
- package/src/components/CanvasSaveButton/README.md +0 -76
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
- package/src/components/CanvasSaveButton/index.js +0 -1
- package/src/components/Copyright/Copyright.test.js +0 -134
- package/src/components/Copyright/README.md +0 -36
- package/src/components/Copyright/index.js +0 -1
- package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
- package/src/components/FeatureExportButton/README.md +0 -76
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
- package/src/components/FeatureExportButton/index.js +0 -1
- package/src/components/FitExtent/FitExtent.test.js +0 -48
- package/src/components/FitExtent/README.md +0 -34
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
- package/src/components/FitExtent/index.js +0 -1
- package/src/components/Geolocation/Geolocation.test.js +0 -267
- package/src/components/Geolocation/README.md +0 -25
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
- package/src/components/Geolocation/index.js +0 -1
- package/src/components/LayerTree/LayerTree.test.js +0 -337
- package/src/components/LayerTree/README.md +0 -92
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
- package/src/components/LayerTree/index.js +0 -1
- package/src/components/MousePosition/MousePosition.test.js +0 -132
- package/src/components/MousePosition/README.md +0 -50
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
- package/src/components/MousePosition/index.js +0 -1
- package/src/components/NorthArrow/NorthArrow.test.js +0 -104
- package/src/components/NorthArrow/README.md +0 -59
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
- package/src/components/NorthArrow/index.js +0 -1
- package/src/components/Overlay/Overlay.test.js +0 -149
- package/src/components/Overlay/README.md +0 -59
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
- package/src/components/Overlay/index.js +0 -1
- package/src/components/Permalink/Permalink.test.js +0 -285
- package/src/components/Permalink/README.md +0 -105
- package/src/components/Permalink/index.js +0 -1
- package/src/components/Popup/Popup.test.js +0 -307
- package/src/components/Popup/README.md +0 -93
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
- package/src/components/Popup/index.js +0 -1
- package/src/components/README.md +0 -41
- package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
- package/src/components/ResizeHandler/index.js +0 -1
- package/src/components/RouteSchedule/README.md +0 -118
- package/src/components/RouteSchedule/RouteSchedule.js +0 -370
- package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
- package/src/components/RouteSchedule/index.js +0 -1
- package/src/components/ScaleLine/README.md +0 -29
- package/src/components/ScaleLine/ScaleLine.test.js +0 -30
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
- package/src/components/ScaleLine/index.js +0 -1
- package/src/components/StopsFinder/README.md +0 -50
- package/src/components/StopsFinder/StopsFinder.test.js +0 -17
- package/src/components/StopsFinder/StopsFinderOption.js +0 -61
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
- package/src/components/StopsFinder/index.js +0 -1
- package/src/components/Zoom/README.md +0 -25
- package/src/components/Zoom/Zoom.test.js +0 -141
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
- package/src/components/Zoom/index.js +0 -1
- package/src/styleguidist/ComponentsList.js +0 -52
- package/src/styleguidist/StyleGuide.js +0 -277
- package/src/styleguidist/styleguidist.css +0 -38
- package/src/utils/GlobalsForOle.js +0 -99
- package/src/utils/KML.js +0 -594
- package/src/utils/KML.test.js +0 -337
- package/src/utils/KMLFormat.test.js +0 -50
- 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/src/utils/getPolygonPattern.test.js +0 -61
- package/src/utils/timeUtils.test.js +0 -30
- package/styleguide.config.js +0 -251
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
- /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
- /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.scss +0 -0
- /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.scss +0 -0
- /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/line.png +0 -0
- /package/{src/images → images}/RouteSchedule/station.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
- /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
- /package/{src/images → images}/favicon.png +0 -0
- /package/{src/images → images}/geops_logo.png +0 -0
- /package/{src/images → images}/geops_logo.svg +0 -0
- /package/{src/images → images}/geops_qr.png +0 -0
- /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
- /package/{src/images → images}/northArrow.svg +0 -0
- /package/{src/images → images}/northArrow.url.svg +0 -0
- /package/{src/images → images}/northArrowCircle.svg +0 -0
- /package/{src/images → images}/northArrowCircle.url.svg +0 -0
- /package/{src/themes → themes}/README.md +0 -0
- /package/{src/themes → themes}/default/components.scss +0 -0
- /package/{src/themes → themes}/default/examples.scss +0 -0
- /package/{src/themes → themes}/default/index.scss +0 -0
- /package/{src/themes → themes}/default/mixins.scss +0 -0
- /package/{src/themes → themes}/default/variables.scss +0 -0
|
@@ -1,54 +1,44 @@
|
|
|
1
|
-
import React, { PureComponent } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import { defaults as defaultInteractions } from
|
|
4
|
-
import { equals } from
|
|
5
|
-
import OLMap from
|
|
6
|
-
import OLCollection from
|
|
7
|
-
import View from
|
|
8
|
-
import { unByKey } from
|
|
9
|
-
import Interaction from
|
|
10
|
-
import { Layer } from
|
|
11
|
-
import ResizeHandler from
|
|
12
|
-
|
|
1
|
+
import React, { PureComponent } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { defaults as defaultInteractions } from "ol/interaction";
|
|
4
|
+
import { equals } from "ol/extent";
|
|
5
|
+
import OLMap from "ol/Map";
|
|
6
|
+
import OLCollection from "ol/Collection";
|
|
7
|
+
import View from "ol/View";
|
|
8
|
+
import { unByKey } from "ol/Observable";
|
|
9
|
+
import Interaction from "ol/interaction/Interaction";
|
|
10
|
+
import { Layer } from "mobility-toolbox-js/ol";
|
|
11
|
+
import ResizeHandler from "../ResizeHandler";
|
|
13
12
|
const propTypes = {
|
|
14
13
|
/** Map animation options */
|
|
15
14
|
animationOptions: PropTypes.shape({
|
|
16
15
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
17
16
|
resolution: PropTypes.number,
|
|
18
|
-
zoom: PropTypes.number
|
|
17
|
+
zoom: PropTypes.number
|
|
19
18
|
}),
|
|
20
|
-
|
|
21
19
|
/** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */
|
|
22
20
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
23
|
-
|
|
24
21
|
/** Class name of the map container */
|
|
25
22
|
className: PropTypes.string,
|
|
26
|
-
|
|
27
23
|
/** Map extent */
|
|
28
24
|
extent: PropTypes.arrayOf(PropTypes.number),
|
|
29
|
-
|
|
30
25
|
/** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */
|
|
31
26
|
fitOptions: PropTypes.object,
|
|
32
|
-
|
|
33
27
|
/** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */
|
|
34
28
|
interactions: PropTypes.oneOfType([
|
|
35
29
|
PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),
|
|
36
|
-
PropTypes.instanceOf(OLCollection)
|
|
30
|
+
PropTypes.instanceOf(OLCollection)
|
|
37
31
|
]),
|
|
38
|
-
|
|
39
32
|
/** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */
|
|
40
33
|
layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
|
|
41
|
-
|
|
42
34
|
/** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */
|
|
43
35
|
map: PropTypes.instanceOf(OLMap),
|
|
44
|
-
|
|
45
36
|
/**
|
|
46
37
|
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.
|
|
47
38
|
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
48
39
|
* @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).
|
|
49
40
|
*/
|
|
50
41
|
onFeaturesClick: PropTypes.func,
|
|
51
|
-
|
|
52
42
|
/**
|
|
53
43
|
* Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.
|
|
54
44
|
* https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel
|
|
@@ -56,145 +46,105 @@ const propTypes = {
|
|
|
56
46
|
featuresClickOptions: PropTypes.shape({
|
|
57
47
|
layerFilter: PropTypes.func,
|
|
58
48
|
hitTolerance: PropTypes.number,
|
|
59
|
-
checkWrapped: PropTypes.bool
|
|
49
|
+
checkWrapped: PropTypes.bool
|
|
60
50
|
}),
|
|
61
|
-
|
|
62
51
|
/**
|
|
63
52
|
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.
|
|
64
53
|
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
65
54
|
* @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).
|
|
66
55
|
*/
|
|
67
56
|
onFeaturesHover: PropTypes.func,
|
|
68
|
-
|
|
69
57
|
/**
|
|
70
58
|
* Callback when the map was moved.
|
|
71
59
|
* @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).
|
|
72
60
|
*/
|
|
73
61
|
onMapMoved: PropTypes.func,
|
|
74
|
-
|
|
75
62
|
/** Map resolution */
|
|
76
63
|
resolution: PropTypes.number,
|
|
77
|
-
|
|
78
64
|
/** The tabIndex of the map. */
|
|
79
65
|
tabIndex: PropTypes.number,
|
|
80
|
-
|
|
81
66
|
/** The style of the map. */
|
|
82
67
|
style: PropTypes.object,
|
|
83
|
-
|
|
84
68
|
/** HTML aria-label. */
|
|
85
69
|
ariaLabel: PropTypes.string,
|
|
86
|
-
|
|
87
70
|
/** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */
|
|
88
71
|
viewOptions: PropTypes.shape({
|
|
89
72
|
minZoom: PropTypes.number,
|
|
90
73
|
maxZoom: PropTypes.number,
|
|
91
74
|
extent: PropTypes.array,
|
|
92
|
-
projection: PropTypes.string
|
|
75
|
+
projection: PropTypes.string
|
|
93
76
|
}),
|
|
94
|
-
|
|
95
77
|
/** Map zoom level */
|
|
96
|
-
zoom: PropTypes.number
|
|
78
|
+
zoom: PropTypes.number
|
|
97
79
|
};
|
|
98
|
-
|
|
99
80
|
const defaultProps = {
|
|
100
|
-
animationOptions:
|
|
81
|
+
animationOptions: void 0,
|
|
101
82
|
center: [0, 0],
|
|
102
|
-
className:
|
|
103
|
-
extent:
|
|
83
|
+
className: "rs-map",
|
|
84
|
+
extent: void 0,
|
|
104
85
|
fitOptions: {
|
|
105
|
-
duration:
|
|
86
|
+
duration: 1e3,
|
|
106
87
|
padding: [20, 20, 20, 20],
|
|
107
|
-
maxZoom: 23
|
|
88
|
+
maxZoom: 23
|
|
108
89
|
},
|
|
109
|
-
style:
|
|
90
|
+
style: void 0,
|
|
110
91
|
interactions: null,
|
|
111
92
|
layers: [],
|
|
112
93
|
map: null,
|
|
113
|
-
onFeaturesClick:
|
|
94
|
+
onFeaturesClick: void 0,
|
|
114
95
|
featuresClickOptions: {
|
|
115
|
-
hitTolerance: 0
|
|
96
|
+
hitTolerance: 0
|
|
116
97
|
},
|
|
117
|
-
onFeaturesHover:
|
|
118
|
-
onMapMoved:
|
|
119
|
-
resolution:
|
|
120
|
-
tabIndex:
|
|
121
|
-
ariaLabel:
|
|
98
|
+
onFeaturesHover: void 0,
|
|
99
|
+
onMapMoved: void 0,
|
|
100
|
+
resolution: void 0,
|
|
101
|
+
tabIndex: void 0,
|
|
102
|
+
ariaLabel: "map",
|
|
122
103
|
viewOptions: {
|
|
123
104
|
minZoom: 0,
|
|
124
105
|
maxZoom: 22,
|
|
125
|
-
extent:
|
|
126
|
-
projection:
|
|
106
|
+
extent: void 0,
|
|
107
|
+
projection: "EPSG:3857"
|
|
127
108
|
},
|
|
128
|
-
zoom: 1
|
|
109
|
+
zoom: 1
|
|
129
110
|
};
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
133
|
-
*
|
|
134
|
-
* The map's view is created with the following parameters for the view:
|
|
135
|
-
* - projection: 'EPSG:3857'
|
|
136
|
-
* - zoom: 0
|
|
137
|
-
* - minZoom: 0
|
|
138
|
-
* - maxZoom: 22
|
|
139
|
-
*
|
|
140
|
-
* These options can be overridden using the viewOptions property.
|
|
141
|
-
*/
|
|
142
111
|
class BasicMap extends PureComponent {
|
|
143
112
|
constructor(props) {
|
|
144
113
|
super(props);
|
|
145
114
|
const { map, interactions } = this.props;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
defaultInteractions({
|
|
154
|
-
altShiftDragRotate: false,
|
|
155
|
-
pinchRotate: false,
|
|
156
|
-
}),
|
|
157
|
-
});
|
|
158
|
-
|
|
115
|
+
this.map = map || new OLMap({
|
|
116
|
+
controls: [],
|
|
117
|
+
interactions: interactions || defaultInteractions({
|
|
118
|
+
altShiftDragRotate: false,
|
|
119
|
+
pinchRotate: false
|
|
120
|
+
})
|
|
121
|
+
});
|
|
159
122
|
this.state = {
|
|
160
|
-
node: null
|
|
123
|
+
node: null
|
|
161
124
|
};
|
|
162
|
-
|
|
163
125
|
this.layers = [];
|
|
164
126
|
this.moveEndRef = null;
|
|
165
127
|
this.singleClickRef = null;
|
|
166
128
|
this.pointerMoveRef = null;
|
|
167
129
|
this.setNode = this.setNode.bind(this);
|
|
168
130
|
}
|
|
169
|
-
|
|
170
131
|
componentDidMount() {
|
|
171
|
-
const { layers, extent, viewOptions, center, zoom, resolution } =
|
|
172
|
-
this.props;
|
|
132
|
+
const { layers, extent, viewOptions, center, zoom, resolution } = this.props;
|
|
173
133
|
const { node } = this.state;
|
|
174
134
|
this.map.setTarget(node);
|
|
175
|
-
|
|
176
|
-
// We set the view here otherwise the map is not correctly zoomed.
|
|
177
135
|
this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));
|
|
178
|
-
|
|
179
|
-
// // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,
|
|
180
|
-
// // so we have to force it to none for mobile.
|
|
181
|
-
// // https://github.com/openlayers/openlayers/pull/10187/files
|
|
182
136
|
const viewPort = this.map.getViewport();
|
|
183
|
-
viewPort.style.touchAction =
|
|
184
|
-
viewPort.style.msTouchAction =
|
|
185
|
-
viewPort.setAttribute(
|
|
186
|
-
|
|
187
|
-
// Fit only work if the map has a size.
|
|
137
|
+
viewPort.style.touchAction = "none";
|
|
138
|
+
viewPort.style.msTouchAction = "none";
|
|
139
|
+
viewPort.setAttribute("touch-action", "none");
|
|
188
140
|
if (this.map.getSize() && extent) {
|
|
189
141
|
this.map.getView().fit(extent);
|
|
190
142
|
}
|
|
191
|
-
|
|
192
143
|
this.setLayers(layers);
|
|
193
144
|
this.listenMoveEnd();
|
|
194
145
|
this.listenSingleClick();
|
|
195
146
|
this.listenPointerMove();
|
|
196
147
|
}
|
|
197
|
-
|
|
198
148
|
componentDidUpdate(prevProps, prevState) {
|
|
199
149
|
const {
|
|
200
150
|
animationOptions,
|
|
@@ -207,82 +157,66 @@ class BasicMap extends PureComponent {
|
|
|
207
157
|
zoom,
|
|
208
158
|
onMapMoved,
|
|
209
159
|
onFeaturesClick,
|
|
210
|
-
onFeaturesHover
|
|
160
|
+
onFeaturesHover
|
|
211
161
|
} = this.props;
|
|
212
162
|
const { node } = this.state;
|
|
213
|
-
|
|
214
163
|
if (prevState.node !== node) {
|
|
164
|
+
if (zoom) {
|
|
165
|
+
this.map.getView().setZoom(zoom);
|
|
166
|
+
}
|
|
167
|
+
if (resolution) {
|
|
168
|
+
this.map.getView().setResolution(resolution);
|
|
169
|
+
}
|
|
215
170
|
this.map.setTarget(node);
|
|
216
|
-
|
|
217
|
-
// When the node is set we reinitialize the extent with the extent property.
|
|
218
171
|
if (!prevState.node && node && extent) {
|
|
219
172
|
this.map.getView().fit(extent);
|
|
220
173
|
}
|
|
221
174
|
}
|
|
222
|
-
|
|
223
175
|
if (prevProps.layers !== layers) {
|
|
224
176
|
this.setLayers(layers, prevProps.layers);
|
|
225
177
|
}
|
|
226
|
-
|
|
227
|
-
// Creates a new view if necessary before updating the others prop.
|
|
228
|
-
if (
|
|
229
|
-
viewOptions &&
|
|
230
|
-
JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)
|
|
231
|
-
) {
|
|
232
|
-
// Re-create a view, ol doesn't provide any method to setExtent of view.
|
|
178
|
+
if (viewOptions && JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)) {
|
|
233
179
|
this.map.setView(
|
|
234
180
|
new View({
|
|
235
181
|
...viewOptions,
|
|
236
182
|
center,
|
|
237
183
|
resolution,
|
|
238
|
-
zoom
|
|
239
|
-
})
|
|
184
|
+
zoom
|
|
185
|
+
})
|
|
240
186
|
);
|
|
241
187
|
}
|
|
242
|
-
|
|
243
188
|
const view = this.map.getView();
|
|
244
|
-
|
|
245
189
|
if (animationOptions && prevProps.animationOptions !== animationOptions) {
|
|
246
190
|
view.animate(animationOptions);
|
|
247
191
|
}
|
|
248
|
-
|
|
249
192
|
if (prevProps.center !== center) {
|
|
250
193
|
view.setCenter(center);
|
|
251
194
|
}
|
|
252
|
-
|
|
253
195
|
if (zoom !== prevProps.zoom) {
|
|
254
196
|
view.setZoom(zoom);
|
|
255
197
|
}
|
|
256
|
-
|
|
257
198
|
if (resolution !== prevProps.resolution) {
|
|
258
199
|
view.setResolution(resolution);
|
|
259
200
|
}
|
|
260
|
-
|
|
261
201
|
if (extent && !equals(extent, prevProps.extent || [])) {
|
|
262
202
|
view.fit(extent, fitOptions);
|
|
263
203
|
}
|
|
264
|
-
|
|
265
204
|
if (onMapMoved !== prevProps.onMapMoved) {
|
|
266
205
|
this.listenMoveEnd();
|
|
267
206
|
}
|
|
268
|
-
|
|
269
207
|
if (onFeaturesClick !== prevProps.onFeaturesClick) {
|
|
270
208
|
this.listenSingleClick();
|
|
271
209
|
}
|
|
272
|
-
|
|
273
210
|
if (onFeaturesHover !== prevProps.onFeaturesHover) {
|
|
274
211
|
this.listenPointerMove();
|
|
275
212
|
}
|
|
276
213
|
}
|
|
277
|
-
|
|
278
214
|
componentWillUnmount() {
|
|
279
215
|
unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);
|
|
280
216
|
}
|
|
281
|
-
|
|
282
217
|
setNode(node) {
|
|
283
218
|
this.setState({ node });
|
|
284
219
|
}
|
|
285
|
-
|
|
286
220
|
setLayers(layers = [], prevLayers = []) {
|
|
287
221
|
for (let i = 0; i < prevLayers.length; i += 1) {
|
|
288
222
|
this.terminateLayer(prevLayers[i]);
|
|
@@ -292,21 +226,14 @@ class BasicMap extends PureComponent {
|
|
|
292
226
|
}
|
|
293
227
|
this.layers = layers;
|
|
294
228
|
}
|
|
295
|
-
|
|
296
229
|
initLayer(layer) {
|
|
297
230
|
if (layer.attachToMap) {
|
|
298
231
|
layer.attachToMap(this.map);
|
|
299
232
|
}
|
|
300
|
-
|
|
301
233
|
if (layer.init) {
|
|
302
234
|
layer.init(this.map);
|
|
303
235
|
}
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
layer.olLayer &&
|
|
307
|
-
this.map.getLayers() &&
|
|
308
|
-
!this.map.getLayers().getArray().includes(layer.olLayer)
|
|
309
|
-
) {
|
|
236
|
+
if (layer.olLayer && this.map.getLayers() && !this.map.getLayers().getArray().includes(layer.olLayer)) {
|
|
310
237
|
this.map.addLayer(layer.olLayer);
|
|
311
238
|
}
|
|
312
239
|
const layers = layer.children || [];
|
|
@@ -314,100 +241,83 @@ class BasicMap extends PureComponent {
|
|
|
314
241
|
this.initLayer(layers[i]);
|
|
315
242
|
}
|
|
316
243
|
}
|
|
317
|
-
|
|
318
244
|
terminateLayer(layer) {
|
|
319
245
|
const layers = layer.children || [];
|
|
320
246
|
for (let i = 0; i < layers.length; i += 1) {
|
|
321
247
|
this.terminateLayer(layers[i]);
|
|
322
248
|
}
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
layer.olLayer &&
|
|
326
|
-
this.map.getLayers() &&
|
|
327
|
-
this.map.getLayers().getArray().includes(layer.olLayer)
|
|
328
|
-
) {
|
|
249
|
+
if (layer.olLayer && this.map.getLayers() && this.map.getLayers().getArray().includes(layer.olLayer)) {
|
|
329
250
|
this.map.removeLayer(layer.olLayer);
|
|
330
251
|
}
|
|
331
|
-
|
|
332
252
|
if (layer.terminate) {
|
|
333
253
|
layer.terminate(this.map);
|
|
334
254
|
}
|
|
335
|
-
|
|
336
255
|
if (layer.detachFromMap) {
|
|
337
256
|
layer.detachFromMap(this.map);
|
|
338
257
|
}
|
|
339
258
|
}
|
|
340
|
-
|
|
341
259
|
listenMoveEnd() {
|
|
342
260
|
const { onMapMoved } = this.props;
|
|
343
261
|
unByKey(this.moveEndRef);
|
|
344
|
-
|
|
345
262
|
if (!onMapMoved) {
|
|
346
263
|
return;
|
|
347
264
|
}
|
|
348
|
-
|
|
349
|
-
this.moveEndRef = this.map.on('moveend', (evt) => {
|
|
265
|
+
this.moveEndRef = this.map.on("moveend", (evt) => {
|
|
350
266
|
return onMapMoved(evt);
|
|
351
267
|
});
|
|
352
268
|
}
|
|
353
|
-
|
|
354
269
|
listenSingleClick() {
|
|
355
270
|
const { onFeaturesClick, featuresClickOptions } = this.props;
|
|
356
271
|
unByKey(this.singleClickRef);
|
|
357
|
-
|
|
358
272
|
if (!onFeaturesClick) {
|
|
359
273
|
return;
|
|
360
274
|
}
|
|
361
|
-
|
|
362
|
-
this.singleClickRef = this.map.on('singleclick', (evt) => {
|
|
275
|
+
this.singleClickRef = this.map.on("singleclick", (evt) => {
|
|
363
276
|
const features = evt.map.getFeaturesAtPixel(
|
|
364
277
|
evt.pixel,
|
|
365
|
-
featuresClickOptions
|
|
278
|
+
featuresClickOptions
|
|
366
279
|
);
|
|
367
280
|
onFeaturesClick(features || [], evt);
|
|
368
281
|
});
|
|
369
282
|
}
|
|
370
|
-
|
|
371
283
|
listenPointerMove() {
|
|
372
284
|
const { onFeaturesHover } = this.props;
|
|
373
285
|
unByKey(this.pointerMoveRef);
|
|
374
|
-
|
|
375
286
|
if (!onFeaturesHover) {
|
|
376
287
|
return;
|
|
377
288
|
}
|
|
378
|
-
|
|
379
|
-
this.pointerMoveRef = this.map.on('pointermove', (evt) => {
|
|
289
|
+
this.pointerMoveRef = this.map.on("pointermove", (evt) => {
|
|
380
290
|
const features = evt.map.getFeaturesAtPixel(evt.pixel);
|
|
381
291
|
onFeaturesHover(features || [], evt);
|
|
382
292
|
});
|
|
383
293
|
}
|
|
384
|
-
|
|
385
294
|
render() {
|
|
386
295
|
const { className, tabIndex, ariaLabel, style } = this.props;
|
|
387
296
|
const { node } = this.state;
|
|
388
|
-
return (
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
297
|
+
return /* @__PURE__ */ React.createElement(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
className,
|
|
301
|
+
ref: this.setNode,
|
|
302
|
+
role: "presentation",
|
|
303
|
+
"aria-label": ariaLabel,
|
|
304
|
+
tabIndex,
|
|
305
|
+
style
|
|
306
|
+
},
|
|
307
|
+
/* @__PURE__ */ React.createElement(
|
|
308
|
+
ResizeHandler,
|
|
309
|
+
{
|
|
310
|
+
maxHeightBrkpts: null,
|
|
311
|
+
maxWidthBrkpts: null,
|
|
312
|
+
observe: node,
|
|
313
|
+
onResize: () => {
|
|
402
314
|
this.map.updateSize();
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
)
|
|
406
318
|
);
|
|
407
319
|
}
|
|
408
320
|
}
|
|
409
|
-
|
|
410
321
|
BasicMap.propTypes = propTypes;
|
|
411
322
|
BasicMap.defaultProps = defaultProps;
|
|
412
|
-
|
|
413
323
|
export default BasicMap;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/BasicMap/BasicMap.js"],
|
|
4
|
+
"sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport { defaults as defaultInteractions } from 'ol/interaction';\nimport { equals } from 'ol/extent';\nimport OLMap from 'ol/Map';\nimport OLCollection from 'ol/Collection';\nimport View from 'ol/View';\nimport { unByKey } from 'ol/Observable';\nimport Interaction from 'ol/interaction/Interaction';\nimport { Layer } from 'mobility-toolbox-js/ol';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /** Map animation options */\n animationOptions: PropTypes.shape({\n center: PropTypes.arrayOf(PropTypes.number),\n resolution: PropTypes.number,\n zoom: PropTypes.number,\n }),\n\n /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */\n center: PropTypes.arrayOf(PropTypes.number),\n\n /** Class name of the map container */\n className: PropTypes.string,\n\n /** Map extent */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */\n fitOptions: PropTypes.object,\n\n /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */\n interactions: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),\n PropTypes.instanceOf(OLCollection),\n ]),\n\n /** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).\n */\n onFeaturesClick: PropTypes.func,\n\n /**\n * Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.\n * https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel\n */\n featuresClickOptions: PropTypes.shape({\n layerFilter: PropTypes.func,\n hitTolerance: PropTypes.number,\n checkWrapped: PropTypes.bool,\n }),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).\n */\n onFeaturesHover: PropTypes.func,\n\n /**\n * Callback when the map was moved.\n * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).\n */\n onMapMoved: PropTypes.func,\n\n /** Map resolution */\n resolution: PropTypes.number,\n\n /** The tabIndex of the map. */\n tabIndex: PropTypes.number,\n\n /** The style of the map. */\n style: PropTypes.object,\n\n /** HTML aria-label. */\n ariaLabel: PropTypes.string,\n\n /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */\n viewOptions: PropTypes.shape({\n minZoom: PropTypes.number,\n maxZoom: PropTypes.number,\n extent: PropTypes.array,\n projection: PropTypes.string,\n }),\n\n /** Map zoom level */\n zoom: PropTypes.number,\n};\n\nconst defaultProps = {\n animationOptions: undefined,\n center: [0, 0],\n className: 'rs-map',\n extent: undefined,\n fitOptions: {\n duration: 1000,\n padding: [20, 20, 20, 20],\n maxZoom: 23,\n },\n style: undefined,\n interactions: null,\n layers: [],\n map: null,\n onFeaturesClick: undefined,\n featuresClickOptions: {\n hitTolerance: 0,\n },\n onFeaturesHover: undefined,\n onMapMoved: undefined,\n resolution: undefined,\n tabIndex: undefined,\n ariaLabel: 'map',\n viewOptions: {\n minZoom: 0,\n maxZoom: 22,\n extent: undefined,\n projection: 'EPSG:3857',\n },\n zoom: 1,\n};\n\n/**\n * The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n *\n * The map's view is created with the following parameters for the view:\n * - projection: 'EPSG:3857'\n * - zoom: 0\n * - minZoom: 0\n * - maxZoom: 22\n *\n * These options can be overridden using the viewOptions property.\n */\nclass BasicMap extends PureComponent {\n constructor(props) {\n super(props);\n const { map, interactions } = this.props;\n\n this.map =\n map ||\n new OLMap({\n controls: [],\n interactions:\n interactions ||\n defaultInteractions({\n altShiftDragRotate: false,\n pinchRotate: false,\n }),\n });\n\n this.state = {\n node: null,\n };\n\n this.layers = [];\n this.moveEndRef = null;\n this.singleClickRef = null;\n this.pointerMoveRef = null;\n this.setNode = this.setNode.bind(this);\n }\n\n componentDidMount() {\n const { layers, extent, viewOptions, center, zoom, resolution } =\n this.props;\n const { node } = this.state;\n this.map.setTarget(node);\n\n // We set the view here otherwise the map is not correctly zoomed.\n this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));\n\n // // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,\n // // so we have to force it to none for mobile.\n // // https://github.com/openlayers/openlayers/pull/10187/files\n const viewPort = this.map.getViewport();\n viewPort.style.touchAction = 'none';\n viewPort.style.msTouchAction = 'none';\n viewPort.setAttribute('touch-action', 'none');\n\n // Fit only work if the map has a size.\n if (this.map.getSize() && extent) {\n this.map.getView().fit(extent);\n }\n\n this.setLayers(layers);\n this.listenMoveEnd();\n this.listenSingleClick();\n this.listenPointerMove();\n }\n\n componentDidUpdate(prevProps, prevState) {\n const {\n animationOptions,\n center,\n extent,\n fitOptions,\n layers,\n resolution,\n viewOptions,\n zoom,\n onMapMoved,\n onFeaturesClick,\n onFeaturesHover,\n } = this.props;\n const { node } = this.state;\n\n if (prevState.node !== node) {\n if (zoom) {\n this.map.getView().setZoom(zoom);\n }\n\n if (resolution) {\n this.map.getView().setResolution(resolution);\n }\n this.map.setTarget(node);\n\n // When the node is set we reinitialize the extent with the extent property.\n if (!prevState.node && node && extent) {\n this.map.getView().fit(extent);\n }\n }\n\n if (prevProps.layers !== layers) {\n this.setLayers(layers, prevProps.layers);\n }\n\n // Creates a new view if necessary before updating the others prop.\n if (\n viewOptions &&\n JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)\n ) {\n // Re-create a view, ol doesn't provide any method to setExtent of view.\n this.map.setView(\n new View({\n ...viewOptions,\n center,\n resolution,\n zoom,\n }),\n );\n }\n\n const view = this.map.getView();\n\n if (animationOptions && prevProps.animationOptions !== animationOptions) {\n view.animate(animationOptions);\n }\n\n if (prevProps.center !== center) {\n view.setCenter(center);\n }\n\n if (zoom !== prevProps.zoom) {\n view.setZoom(zoom);\n }\n\n if (resolution !== prevProps.resolution) {\n view.setResolution(resolution);\n }\n\n if (extent && !equals(extent, prevProps.extent || [])) {\n view.fit(extent, fitOptions);\n }\n\n if (onMapMoved !== prevProps.onMapMoved) {\n this.listenMoveEnd();\n }\n\n if (onFeaturesClick !== prevProps.onFeaturesClick) {\n this.listenSingleClick();\n }\n\n if (onFeaturesHover !== prevProps.onFeaturesHover) {\n this.listenPointerMove();\n }\n }\n\n componentWillUnmount() {\n unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);\n }\n\n setNode(node) {\n this.setState({ node });\n }\n\n setLayers(layers = [], prevLayers = []) {\n for (let i = 0; i < prevLayers.length; i += 1) {\n this.terminateLayer(prevLayers[i]);\n }\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n this.layers = layers;\n }\n\n initLayer(layer) {\n if (layer.attachToMap) {\n layer.attachToMap(this.map);\n }\n\n if (layer.init) {\n layer.init(this.map);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n !this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.addLayer(layer.olLayer);\n }\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n terminateLayer(layer) {\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.terminateLayer(layers[i]);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.removeLayer(layer.olLayer);\n }\n\n if (layer.terminate) {\n layer.terminate(this.map);\n }\n\n if (layer.detachFromMap) {\n layer.detachFromMap(this.map);\n }\n }\n\n listenMoveEnd() {\n const { onMapMoved } = this.props;\n unByKey(this.moveEndRef);\n\n if (!onMapMoved) {\n return;\n }\n\n this.moveEndRef = this.map.on('moveend', (evt) => {\n return onMapMoved(evt);\n });\n }\n\n listenSingleClick() {\n const { onFeaturesClick, featuresClickOptions } = this.props;\n unByKey(this.singleClickRef);\n\n if (!onFeaturesClick) {\n return;\n }\n\n this.singleClickRef = this.map.on('singleclick', (evt) => {\n const features = evt.map.getFeaturesAtPixel(\n evt.pixel,\n featuresClickOptions,\n );\n onFeaturesClick(features || [], evt);\n });\n }\n\n listenPointerMove() {\n const { onFeaturesHover } = this.props;\n unByKey(this.pointerMoveRef);\n\n if (!onFeaturesHover) {\n return;\n }\n\n this.pointerMoveRef = this.map.on('pointermove', (evt) => {\n const features = evt.map.getFeaturesAtPixel(evt.pixel);\n onFeaturesHover(features || [], evt);\n });\n }\n\n render() {\n const { className, tabIndex, ariaLabel, style } = this.props;\n const { node } = this.state;\n return (\n <div\n className={className}\n ref={this.setNode}\n role=\"presentation\"\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n style={style}\n >\n <ResizeHandler\n maxHeightBrkpts={null}\n maxWidthBrkpts={null}\n observe={node}\n onResize={() => {\n this.map.updateSize();\n }}\n />\n </div>\n );\n }\n}\n\nBasicMap.propTypes = propTypes;\nBasicMap.defaultProps = defaultProps;\n\nexport default BasicMap;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AACtB,SAAS,YAAY,2BAA2B;AAChD,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,OAAO,kBAAkB;AACzB,OAAO,UAAU;AACjB,SAAS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