react-spatial 1.2.2 → 1.2.3-beta.1
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 +163 -221
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
- package/components/BaseLayerSwitcher/index.js +1 -3
- package/components/BaseLayerSwitcher/index.js.map +7 -1
- package/components/BasicMap/BasicMap.js +147 -285
- package/components/BasicMap/BasicMap.js.map +7 -1
- package/components/BasicMap/index.js +1 -3
- package/components/BasicMap/index.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +165 -419
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
- package/components/CanvasSaveButton/index.js +1 -3
- package/components/CanvasSaveButton/index.js.map +7 -1
- package/components/Copyright/Copyright.js +29 -70
- package/components/Copyright/Copyright.js.map +7 -1
- package/components/Copyright/index.js +1 -3
- package/components/Copyright/index.js.map +7 -1
- package/components/FeatureExportButton/FeatureExportButton.js +40 -106
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
- package/components/FeatureExportButton/index.js +1 -3
- package/components/FeatureExportButton/index.js.map +7 -1
- package/components/FilterButton/FilterButton.js +41 -106
- package/components/FilterButton/FilterButton.js.map +7 -1
- package/components/FilterButton/index.js +1 -3
- package/components/FilterButton/index.js.map +7 -1
- package/components/FitExtent/FitExtent.js +17 -50
- package/components/FitExtent/FitExtent.js.map +7 -1
- package/components/FitExtent/index.js +1 -3
- package/components/FitExtent/index.js.map +7 -1
- package/components/FollowButton/FollowButton.js +41 -111
- package/components/FollowButton/FollowButton.js.map +7 -1
- package/components/FollowButton/index.js +1 -3
- package/components/FollowButton/index.js.map +7 -1
- package/components/Geolocation/Geolocation.js +104 -213
- package/components/Geolocation/Geolocation.js.map +7 -1
- package/components/Geolocation/index.js +1 -3
- package/components/Geolocation/index.js.map +7 -1
- package/components/LayerTree/LayerTree.js +204 -410
- package/components/LayerTree/LayerTree.js.map +7 -1
- package/components/LayerTree/index.js +1 -3
- package/components/LayerTree/index.js.map +7 -1
- package/components/MousePosition/MousePosition.js +61 -130
- package/components/MousePosition/MousePosition.js.map +7 -1
- package/components/MousePosition/index.js +1 -3
- package/components/MousePosition/index.js.map +7 -1
- package/components/NorthArrow/NorthArrow.js +22 -62
- package/components/NorthArrow/NorthArrow.js.map +7 -1
- package/components/NorthArrow/index.js +1 -3
- package/components/NorthArrow/index.js.map +7 -1
- package/components/Overlay/Overlay.js +83 -130
- package/components/Overlay/Overlay.js.map +7 -1
- package/components/Overlay/index.js +1 -3
- package/components/Overlay/index.js.map +7 -1
- package/components/Permalink/Permalink.js +150 -244
- package/components/Permalink/Permalink.js.map +7 -1
- package/components/Permalink/index.js +1 -3
- package/components/Permalink/index.js.map +7 -1
- package/components/Popup/Popup.js +106 -233
- package/components/Popup/Popup.js.map +7 -1
- package/components/Popup/index.js +1 -3
- package/components/Popup/index.js.map +7 -1
- package/components/ResizeHandler/ResizeHandler.js +58 -113
- package/components/ResizeHandler/ResizeHandler.js.map +7 -1
- package/components/ResizeHandler/index.js +1 -3
- package/components/ResizeHandler/index.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.js +150 -283
- package/components/RouteSchedule/RouteSchedule.js.map +7 -1
- package/components/RouteSchedule/index.js +1 -3
- package/components/RouteSchedule/index.js.map +7 -1
- package/components/ScaleLine/ScaleLine.js +21 -45
- package/components/ScaleLine/ScaleLine.js.map +7 -1
- package/components/ScaleLine/index.js +1 -3
- package/components/ScaleLine/index.js.map +7 -1
- package/components/Search/Search.js +122 -186
- package/components/Search/Search.js.map +7 -1
- package/components/Search/SearchService.js +45 -69
- package/components/Search/SearchService.js.map +7 -1
- package/components/Search/engines/Engine.js +18 -25
- package/components/Search/engines/Engine.js.map +7 -1
- package/components/Search/engines/StopFinder.js +21 -38
- package/components/Search/engines/StopFinder.js.map +7 -1
- package/components/Search/index.js +3 -6
- package/components/Search/index.js.map +7 -1
- package/components/StopsFinder/StopsFinder.js +123 -174
- package/components/StopsFinder/StopsFinder.js.map +7 -1
- package/components/StopsFinder/StopsFinderOption.js +37 -54
- package/components/StopsFinder/StopsFinderOption.js.map +7 -1
- package/components/StopsFinder/index.js +1 -3
- package/components/StopsFinder/index.js.map +7 -1
- package/components/TrackerControl/TrackerControl.js +73 -128
- package/components/TrackerControl/TrackerControl.js.map +7 -1
- package/components/TrackerControl/index.js +1 -3
- package/components/TrackerControl/index.js.map +7 -1
- package/components/Zoom/Zoom.js +69 -112
- package/components/Zoom/Zoom.js.map +7 -1
- package/components/Zoom/index.js +1 -3
- package/components/Zoom/index.js.map +7 -1
- package/package.json +10 -5
- package/themes/default/components.scss +0 -1
- package/themes/default/examples.scss +0 -1
- package/utils/GlobalsForOle.js +63 -64
- package/utils/GlobalsForOle.js.map +7 -1
- package/utils/KML.js +178 -364
- package/utils/KML.js.map +7 -1
- package/utils/KMLFormat.js +37 -73
- package/utils/KMLFormat.js.map +7 -1
- package/utils/Styles.js +24 -32
- package/utils/Styles.js.map +7 -1
- package/utils/getPolygonPattern.js +11 -44
- package/utils/getPolygonPattern.js.map +7 -1
- package/utils/timeUtils.js +16 -35
- package/utils/timeUtils.js.map +7 -1
- package/LayerService.js +0 -193
- package/LayerService.js.map +0 -1
- package/LayerService.test.js +0 -160
- package/LayerService.test.js.map +0 -1
- package/Projections.js +0 -16
- package/Projections.js.map +0 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
- package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
- package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
- package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
- package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
- package/components/BaseLayerToggler/index.js +0 -3
- package/components/BaseLayerToggler/index.js.map +0 -1
- package/components/BasicMap/BasicMap.test.js +0 -288
- package/components/BasicMap/BasicMap.test.js.map +0 -1
- package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
- package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
- package/components/Copyright/Copyright.test.js +0 -133
- package/components/Copyright/Copyright.test.js.map +0 -1
- package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
- package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
- package/components/FilterButton/FilterButton.test.js +0 -48
- package/components/FilterButton/FilterButton.test.js.map +0 -1
- package/components/FitExtent/FitExtent.test.js +0 -44
- package/components/FitExtent/FitExtent.test.js.map +0 -1
- package/components/FollowButton/FollowButton.test.js +0 -57
- package/components/FollowButton/FollowButton.test.js.map +0 -1
- package/components/Geolocation/Geolocation.test.js +0 -263
- package/components/Geolocation/Geolocation.test.js.map +0 -1
- package/components/LayerTree/LayerTree.test.js +0 -323
- package/components/LayerTree/LayerTree.test.js.map +0 -1
- package/components/MousePosition/MousePosition.test.js +0 -125
- package/components/MousePosition/MousePosition.test.js.map +0 -1
- package/components/NorthArrow/NorthArrow.test.js +0 -106
- package/components/NorthArrow/NorthArrow.test.js.map +0 -1
- package/components/Overlay/Overlay.test.js +0 -145
- package/components/Overlay/Overlay.test.js.map +0 -1
- package/components/Permalink/Permalink.test.js +0 -267
- package/components/Permalink/Permalink.test.js.map +0 -1
- package/components/Popup/Popup.test.js +0 -291
- package/components/Popup/Popup.test.js.map +0 -1
- package/components/ResizeHandler/ResizeHandler.test.js +0 -410
- package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
- package/components/RouteSchedule/RouteSchedule.test.js +0 -102
- package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
- package/components/ScaleLine/ScaleLine.test.js +0 -32
- package/components/ScaleLine/ScaleLine.test.js.map +0 -1
- package/components/Search/Search.test.js +0 -15
- package/components/Search/Search.test.js.map +0 -1
- package/components/StopsFinder/StopsFinder.test.js +0 -19
- package/components/StopsFinder/StopsFinder.test.js.map +0 -1
- package/components/TrackerControl/TrackerControl.test.js +0 -17
- package/components/TrackerControl/TrackerControl.test.js.map +0 -1
- package/components/Zoom/Zoom.test.js +0 -150
- package/components/Zoom/Zoom.test.js.map +0 -1
- package/propTypes.js +0 -55
- package/propTypes.js.map +0 -1
- package/setupTests.js +0 -5
- package/setupTests.js.map +0 -1
- package/styleguidist/ComponentsList.js +0 -52
- package/styleguidist/ComponentsList.js.map +0 -1
- package/styleguidist/StyleGuide.js +0 -253
- package/styleguidist/StyleGuide.js.map +0 -1
- package/utils/KML.test.js +0 -163
- package/utils/KML.test.js.map +0 -1
- package/utils/KMLFormat.test.js +0 -22
- package/utils/KMLFormat.test.js.map +0 -1
- package/utils/getPolygonPattern.test.js +0 -66
- package/utils/getPolygonPattern.test.js.map +0 -1
- package/utils/timeUtils.test.js +0 -32
- package/utils/timeUtils.test.js.map +0 -1
|
@@ -1,416 +1,278 @@
|
|
|
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
|
-
|
|
13
|
-
var propTypes = {
|
|
14
|
-
/** Map animation options */
|
|
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";
|
|
12
|
+
const propTypes = {
|
|
15
13
|
animationOptions: PropTypes.shape({
|
|
16
14
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
17
15
|
resolution: PropTypes.number,
|
|
18
|
-
zoom: PropTypes.number
|
|
16
|
+
zoom: PropTypes.number
|
|
19
17
|
}),
|
|
20
|
-
|
|
21
|
-
/** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */
|
|
22
18
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
23
|
-
|
|
24
|
-
/** Class name of the map container */
|
|
25
19
|
className: PropTypes.string,
|
|
26
|
-
|
|
27
|
-
/** Map extent */
|
|
28
20
|
extent: PropTypes.arrayOf(PropTypes.number),
|
|
29
|
-
|
|
30
|
-
/** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */
|
|
31
21
|
fitOptions: PropTypes.object,
|
|
32
|
-
|
|
33
|
-
/** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */
|
|
34
22
|
interactions: PropTypes.oneOfType([
|
|
35
23
|
PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),
|
|
36
|
-
PropTypes.instanceOf(OLCollection)
|
|
37
|
-
|
|
38
|
-
/** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */
|
|
24
|
+
PropTypes.instanceOf(OLCollection)
|
|
25
|
+
]),
|
|
39
26
|
layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
|
|
40
|
-
|
|
41
|
-
/** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */
|
|
42
27
|
map: PropTypes.instanceOf(OLMap),
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.
|
|
46
|
-
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
47
|
-
* @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).
|
|
48
|
-
*/
|
|
49
28
|
onFeaturesClick: PropTypes.func,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.
|
|
53
|
-
* https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel
|
|
54
|
-
*/
|
|
55
29
|
featuresClickOptions: PropTypes.shape({
|
|
56
30
|
layerFilter: PropTypes.func,
|
|
57
31
|
hitTolerance: PropTypes.number,
|
|
58
|
-
checkWrapped: PropTypes.bool
|
|
32
|
+
checkWrapped: PropTypes.bool
|
|
59
33
|
}),
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.
|
|
63
|
-
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
64
|
-
* @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).
|
|
65
|
-
*/
|
|
66
34
|
onFeaturesHover: PropTypes.func,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Callback when the map was moved.
|
|
70
|
-
* @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).
|
|
71
|
-
*/
|
|
72
35
|
onMapMoved: PropTypes.func,
|
|
73
|
-
|
|
74
|
-
/** Map resolution */
|
|
75
36
|
resolution: PropTypes.number,
|
|
76
|
-
|
|
77
|
-
/** The tabIndex of the map. */
|
|
78
37
|
tabIndex: PropTypes.number,
|
|
79
|
-
|
|
80
|
-
/** The style of the map. */
|
|
81
38
|
style: PropTypes.object,
|
|
82
|
-
|
|
83
|
-
/** HTML aria-label. */
|
|
84
39
|
ariaLabel: PropTypes.string,
|
|
85
|
-
|
|
86
|
-
/** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */
|
|
87
40
|
viewOptions: PropTypes.shape({
|
|
88
41
|
minZoom: PropTypes.number,
|
|
89
42
|
maxZoom: PropTypes.number,
|
|
90
43
|
extent: PropTypes.array,
|
|
91
|
-
projection: PropTypes.string
|
|
44
|
+
projection: PropTypes.string
|
|
92
45
|
}),
|
|
93
|
-
|
|
94
|
-
/** Map zoom level */
|
|
95
|
-
zoom: PropTypes.number,
|
|
46
|
+
zoom: PropTypes.number
|
|
96
47
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
animationOptions: undefined,
|
|
48
|
+
const defaultProps = {
|
|
49
|
+
animationOptions: void 0,
|
|
100
50
|
center: [0, 0],
|
|
101
|
-
className:
|
|
102
|
-
extent:
|
|
51
|
+
className: "rs-map",
|
|
52
|
+
extent: void 0,
|
|
103
53
|
fitOptions: {
|
|
104
|
-
duration:
|
|
54
|
+
duration: 1e3,
|
|
105
55
|
padding: [20, 20, 20, 20],
|
|
106
|
-
maxZoom: 23
|
|
56
|
+
maxZoom: 23
|
|
107
57
|
},
|
|
108
|
-
style:
|
|
58
|
+
style: void 0,
|
|
109
59
|
interactions: null,
|
|
110
60
|
layers: [],
|
|
111
61
|
map: null,
|
|
112
|
-
onFeaturesClick:
|
|
62
|
+
onFeaturesClick: void 0,
|
|
113
63
|
featuresClickOptions: {
|
|
114
|
-
hitTolerance: 0
|
|
64
|
+
hitTolerance: 0
|
|
115
65
|
},
|
|
116
|
-
onFeaturesHover:
|
|
117
|
-
onMapMoved:
|
|
118
|
-
resolution:
|
|
119
|
-
tabIndex:
|
|
120
|
-
ariaLabel:
|
|
66
|
+
onFeaturesHover: void 0,
|
|
67
|
+
onMapMoved: void 0,
|
|
68
|
+
resolution: void 0,
|
|
69
|
+
tabIndex: void 0,
|
|
70
|
+
ariaLabel: "map",
|
|
121
71
|
viewOptions: {
|
|
122
72
|
minZoom: 0,
|
|
123
73
|
maxZoom: 22,
|
|
124
|
-
extent:
|
|
125
|
-
projection:
|
|
74
|
+
extent: void 0,
|
|
75
|
+
projection: "EPSG:3857"
|
|
126
76
|
},
|
|
127
|
-
zoom: 1
|
|
77
|
+
zoom: 1
|
|
128
78
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*/
|
|
141
|
-
var BasicMap = /*@__PURE__*/(function (PureComponent) {
|
|
142
|
-
function BasicMap(props) {
|
|
143
|
-
PureComponent.call(this, props);
|
|
144
|
-
var ref = this.props;
|
|
145
|
-
var map = ref.map;
|
|
146
|
-
var interactions = ref.interactions;
|
|
147
|
-
|
|
148
|
-
this.map =
|
|
149
|
-
map ||
|
|
150
|
-
new OLMap({
|
|
151
|
-
controls: [],
|
|
152
|
-
interactions:
|
|
153
|
-
interactions ||
|
|
154
|
-
defaultInteractions({
|
|
155
|
-
altShiftDragRotate: false,
|
|
156
|
-
pinchRotate: false,
|
|
157
|
-
}),
|
|
158
|
-
});
|
|
159
|
-
|
|
79
|
+
class BasicMap extends PureComponent {
|
|
80
|
+
constructor(props) {
|
|
81
|
+
super(props);
|
|
82
|
+
const { map, interactions } = this.props;
|
|
83
|
+
this.map = map || new OLMap({
|
|
84
|
+
controls: [],
|
|
85
|
+
interactions: interactions || defaultInteractions({
|
|
86
|
+
altShiftDragRotate: false,
|
|
87
|
+
pinchRotate: false
|
|
88
|
+
})
|
|
89
|
+
});
|
|
160
90
|
this.state = {
|
|
161
|
-
node: null
|
|
91
|
+
node: null
|
|
162
92
|
};
|
|
163
|
-
|
|
164
93
|
this.layers = [];
|
|
165
94
|
this.moveEndRef = null;
|
|
166
95
|
this.singleClickRef = null;
|
|
167
96
|
this.pointerMoveRef = null;
|
|
168
97
|
this.setNode = this.setNode.bind(this);
|
|
169
98
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
BasicMap.prototype.constructor = BasicMap;
|
|
174
|
-
|
|
175
|
-
BasicMap.prototype.componentDidMount = function componentDidMount () {
|
|
176
|
-
var ref =
|
|
177
|
-
this.props;
|
|
178
|
-
var layers = ref.layers;
|
|
179
|
-
var extent = ref.extent;
|
|
180
|
-
var viewOptions = ref.viewOptions;
|
|
181
|
-
var center = ref.center;
|
|
182
|
-
var zoom = ref.zoom;
|
|
183
|
-
var resolution = ref.resolution;
|
|
184
|
-
var ref$1 = this.state;
|
|
185
|
-
var node = ref$1.node;
|
|
99
|
+
componentDidMount() {
|
|
100
|
+
const { layers, extent, viewOptions, center, zoom, resolution } = this.props;
|
|
101
|
+
const { node } = this.state;
|
|
186
102
|
this.map.setTarget(node);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// // so we have to force it to none for mobile.
|
|
193
|
-
// // https://github.com/openlayers/openlayers/pull/10187/files
|
|
194
|
-
var viewPort = this.map.getViewport();
|
|
195
|
-
viewPort.style.touchAction = 'none';
|
|
196
|
-
viewPort.style.msTouchAction = 'none';
|
|
197
|
-
viewPort.setAttribute('touch-action', 'none');
|
|
198
|
-
|
|
199
|
-
// Fit only work if the map has a size.
|
|
103
|
+
this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));
|
|
104
|
+
const viewPort = this.map.getViewport();
|
|
105
|
+
viewPort.style.touchAction = "none";
|
|
106
|
+
viewPort.style.msTouchAction = "none";
|
|
107
|
+
viewPort.setAttribute("touch-action", "none");
|
|
200
108
|
if (this.map.getSize() && extent) {
|
|
201
109
|
this.map.getView().fit(extent);
|
|
202
110
|
}
|
|
203
|
-
|
|
204
111
|
this.setLayers(layers);
|
|
205
112
|
this.listenMoveEnd();
|
|
206
113
|
this.listenSingleClick();
|
|
207
114
|
this.listenPointerMove();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var node = ref$1.node;
|
|
225
|
-
|
|
115
|
+
}
|
|
116
|
+
componentDidUpdate(prevProps, prevState) {
|
|
117
|
+
const {
|
|
118
|
+
animationOptions,
|
|
119
|
+
center,
|
|
120
|
+
extent,
|
|
121
|
+
fitOptions,
|
|
122
|
+
layers,
|
|
123
|
+
resolution,
|
|
124
|
+
viewOptions,
|
|
125
|
+
zoom,
|
|
126
|
+
onMapMoved,
|
|
127
|
+
onFeaturesClick,
|
|
128
|
+
onFeaturesHover
|
|
129
|
+
} = this.props;
|
|
130
|
+
const { node } = this.state;
|
|
226
131
|
if (prevState.node !== node) {
|
|
227
132
|
this.map.setTarget(node);
|
|
228
|
-
|
|
229
|
-
// When the node is set we reinitialize the extent with the extent property.
|
|
230
133
|
if (!prevState.node && node && extent) {
|
|
231
134
|
this.map.getView().fit(extent);
|
|
232
135
|
}
|
|
233
136
|
}
|
|
234
|
-
|
|
235
137
|
if (prevProps.layers !== layers) {
|
|
236
138
|
this.setLayers(layers, prevProps.layers);
|
|
237
139
|
}
|
|
238
|
-
|
|
239
|
-
// Creates a new view if necessary before updating the others prop.
|
|
240
|
-
if (
|
|
241
|
-
viewOptions &&
|
|
242
|
-
JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)
|
|
243
|
-
) {
|
|
244
|
-
// Re-create a view, ol doesn't provide any method to setExtent of view.
|
|
140
|
+
if (viewOptions && JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)) {
|
|
245
141
|
this.map.setView(
|
|
246
|
-
new View(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
142
|
+
new View({
|
|
143
|
+
...viewOptions,
|
|
144
|
+
center,
|
|
145
|
+
resolution,
|
|
146
|
+
zoom
|
|
147
|
+
})
|
|
250
148
|
);
|
|
251
149
|
}
|
|
252
|
-
|
|
253
|
-
var view = this.map.getView();
|
|
254
|
-
|
|
150
|
+
const view = this.map.getView();
|
|
255
151
|
if (animationOptions && prevProps.animationOptions !== animationOptions) {
|
|
256
152
|
view.animate(animationOptions);
|
|
257
153
|
}
|
|
258
|
-
|
|
259
154
|
if (prevProps.center !== center) {
|
|
260
155
|
view.setCenter(center);
|
|
261
156
|
}
|
|
262
|
-
|
|
263
157
|
if (zoom !== prevProps.zoom) {
|
|
264
158
|
view.setZoom(zoom);
|
|
265
159
|
}
|
|
266
|
-
|
|
267
160
|
if (resolution !== prevProps.resolution) {
|
|
268
161
|
view.setResolution(resolution);
|
|
269
162
|
}
|
|
270
|
-
|
|
271
163
|
if (extent && !equals(extent, prevProps.extent || [])) {
|
|
272
164
|
view.fit(extent, fitOptions);
|
|
273
165
|
}
|
|
274
|
-
|
|
275
166
|
if (onMapMoved !== prevProps.onMapMoved) {
|
|
276
167
|
this.listenMoveEnd();
|
|
277
168
|
}
|
|
278
|
-
|
|
279
169
|
if (onFeaturesClick !== prevProps.onFeaturesClick) {
|
|
280
170
|
this.listenSingleClick();
|
|
281
171
|
}
|
|
282
|
-
|
|
283
172
|
if (onFeaturesHover !== prevProps.onFeaturesHover) {
|
|
284
173
|
this.listenPointerMove();
|
|
285
174
|
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
BasicMap.prototype.componentWillUnmount = function componentWillUnmount () {
|
|
175
|
+
}
|
|
176
|
+
componentWillUnmount() {
|
|
289
177
|
unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
BasicMap.prototype.setLayers = function setLayers (layers, prevLayers) {
|
|
297
|
-
if ( layers === void 0 ) layers = [];
|
|
298
|
-
if ( prevLayers === void 0 ) prevLayers = [];
|
|
299
|
-
|
|
300
|
-
for (var i = 0; i < prevLayers.length; i += 1) {
|
|
178
|
+
}
|
|
179
|
+
setNode(node) {
|
|
180
|
+
this.setState({ node });
|
|
181
|
+
}
|
|
182
|
+
setLayers(layers = [], prevLayers = []) {
|
|
183
|
+
for (let i = 0; i < prevLayers.length; i += 1) {
|
|
301
184
|
this.terminateLayer(prevLayers[i]);
|
|
302
185
|
}
|
|
303
|
-
for (
|
|
304
|
-
this.initLayer(layers[i
|
|
186
|
+
for (let i = 0; i < layers.length; i += 1) {
|
|
187
|
+
this.initLayer(layers[i]);
|
|
305
188
|
}
|
|
306
189
|
this.layers = layers;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
this.map
|
|
314
|
-
|
|
315
|
-
) {
|
|
190
|
+
}
|
|
191
|
+
initLayer(layer) {
|
|
192
|
+
if (layer.attachToMap) {
|
|
193
|
+
layer.attachToMap(this.map);
|
|
194
|
+
}
|
|
195
|
+
if (layer.init) {
|
|
196
|
+
layer.init(this.map);
|
|
197
|
+
}
|
|
198
|
+
if (layer.olLayer && this.map.getLayers() && !this.map.getLayers().getArray().includes(layer.olLayer)) {
|
|
316
199
|
this.map.addLayer(layer.olLayer);
|
|
317
200
|
}
|
|
318
|
-
|
|
319
|
-
for (
|
|
201
|
+
const layers = layer.children || [];
|
|
202
|
+
for (let i = 0; i < layers.length; i += 1) {
|
|
320
203
|
this.initLayer(layers[i]);
|
|
321
204
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
) {
|
|
205
|
+
}
|
|
206
|
+
terminateLayer(layer) {
|
|
207
|
+
const layers = layer.children || [];
|
|
208
|
+
for (let i = 0; i < layers.length; i += 1) {
|
|
209
|
+
this.terminateLayer(layers[i]);
|
|
210
|
+
}
|
|
211
|
+
if (layer.olLayer && this.map.getLayers() && this.map.getLayers().getArray().includes(layer.olLayer)) {
|
|
330
212
|
this.map.removeLayer(layer.olLayer);
|
|
331
213
|
}
|
|
332
|
-
layer.terminate
|
|
333
|
-
|
|
334
|
-
for (var i = 0; i < layers.length; i += 1) {
|
|
335
|
-
this.terminateLayer(layers[i]);
|
|
214
|
+
if (layer.terminate) {
|
|
215
|
+
layer.terminate(this.map);
|
|
336
216
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
217
|
+
if (layer.detachFromMap) {
|
|
218
|
+
layer.detachFromMap(this.map);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
listenMoveEnd() {
|
|
222
|
+
const { onMapMoved } = this.props;
|
|
342
223
|
unByKey(this.moveEndRef);
|
|
343
|
-
|
|
344
224
|
if (!onMapMoved) {
|
|
345
225
|
return;
|
|
346
226
|
}
|
|
347
|
-
|
|
348
|
-
this.moveEndRef = this.map.on('moveend', function (evt) {
|
|
227
|
+
this.moveEndRef = this.map.on("moveend", (evt) => {
|
|
349
228
|
return onMapMoved(evt);
|
|
350
229
|
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
var ref = this.props;
|
|
355
|
-
var onFeaturesClick = ref.onFeaturesClick;
|
|
356
|
-
var featuresClickOptions = ref.featuresClickOptions;
|
|
230
|
+
}
|
|
231
|
+
listenSingleClick() {
|
|
232
|
+
const { onFeaturesClick, featuresClickOptions } = this.props;
|
|
357
233
|
unByKey(this.singleClickRef);
|
|
358
|
-
|
|
359
234
|
if (!onFeaturesClick) {
|
|
360
235
|
return;
|
|
361
236
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var features = evt.map.getFeaturesAtPixel(
|
|
237
|
+
this.singleClickRef = this.map.on("singleclick", (evt) => {
|
|
238
|
+
const features = evt.map.getFeaturesAtPixel(
|
|
365
239
|
evt.pixel,
|
|
366
240
|
featuresClickOptions
|
|
367
241
|
);
|
|
368
242
|
onFeaturesClick(features || [], evt);
|
|
369
243
|
});
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
var ref = this.props;
|
|
374
|
-
var onFeaturesHover = ref.onFeaturesHover;
|
|
244
|
+
}
|
|
245
|
+
listenPointerMove() {
|
|
246
|
+
const { onFeaturesHover } = this.props;
|
|
375
247
|
unByKey(this.pointerMoveRef);
|
|
376
|
-
|
|
377
248
|
if (!onFeaturesHover) {
|
|
378
249
|
return;
|
|
379
250
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
var features = evt.map.getFeaturesAtPixel(evt.pixel);
|
|
251
|
+
this.pointerMoveRef = this.map.on("pointermove", (evt) => {
|
|
252
|
+
const features = evt.map.getFeaturesAtPixel(evt.pixel);
|
|
383
253
|
onFeaturesHover(features || [], evt);
|
|
384
254
|
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
return BasicMap;
|
|
409
|
-
}(PureComponent));
|
|
410
|
-
|
|
255
|
+
}
|
|
256
|
+
render() {
|
|
257
|
+
const { className, tabIndex, ariaLabel, style } = this.props;
|
|
258
|
+
const { node } = this.state;
|
|
259
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
260
|
+
className,
|
|
261
|
+
ref: this.setNode,
|
|
262
|
+
role: "presentation",
|
|
263
|
+
"aria-label": ariaLabel,
|
|
264
|
+
tabIndex,
|
|
265
|
+
style
|
|
266
|
+
}, /* @__PURE__ */ React.createElement(ResizeHandler, {
|
|
267
|
+
maxHeightBrkpts: null,
|
|
268
|
+
maxWidthBrkpts: null,
|
|
269
|
+
observe: node,
|
|
270
|
+
onResize: () => {
|
|
271
|
+
this.map.updateSize();
|
|
272
|
+
}
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
411
276
|
BasicMap.propTypes = propTypes;
|
|
412
277
|
BasicMap.defaultProps = defaultProps;
|
|
413
|
-
|
|
414
278
|
export default BasicMap;
|
|
415
|
-
|
|
416
|
-
//# sourceMappingURL=BasicMap.js.map
|