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