react-spatial 1.12.0 → 1.12.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 +51 -51
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +2 -2
- package/components/BasicMap/BasicMap.js +80 -80
- package/components/BasicMap/BasicMap.js.map +2 -2
- package/components/CanvasSaveButton/CanvasSaveButton.js +68 -68
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +2 -2
- package/components/Copyright/Copyright.js +12 -12
- package/components/Copyright/Copyright.js.map +2 -2
- package/components/FeatureExportButton/FeatureExportButton.js +5 -5
- package/components/FeatureExportButton/FeatureExportButton.js.map +2 -2
- package/components/FitExtent/FitExtent.js +15 -15
- package/components/FitExtent/FitExtent.js.map +2 -2
- package/components/Geolocation/Geolocation.js +96 -96
- package/components/Geolocation/Geolocation.js.map +2 -2
- package/components/LayerTree/LayerTree.js +172 -172
- package/components/LayerTree/LayerTree.js.map +2 -2
- package/components/MousePosition/MousePosition.js +27 -27
- package/components/MousePosition/MousePosition.js.map +2 -2
- package/components/NorthArrow/NorthArrow.js +13 -13
- package/components/NorthArrow/NorthArrow.js.map +2 -2
- package/components/Overlay/Overlay.js +49 -49
- package/components/Overlay/Overlay.js.map +2 -2
- package/components/Permalink/Permalink.js +70 -70
- package/components/Permalink/Permalink.js.map +2 -2
- package/components/Popup/Popup.js +73 -73
- package/components/Popup/Popup.js.map +2 -2
- package/components/ResizeHandler/ResizeHandler.js +51 -49
- package/components/ResizeHandler/ResizeHandler.js.map +2 -2
- package/components/RouteSchedule/RouteSchedule.js +86 -74
- package/components/RouteSchedule/RouteSchedule.js.map +2 -2
- package/components/RouteSchedule/RouteSchedule.scss +0 -20
- package/components/ScaleLine/ScaleLine.js +2 -2
- package/components/ScaleLine/ScaleLine.js.map +2 -2
- package/components/StopsFinder/StopsFinder.js +21 -21
- package/components/StopsFinder/StopsFinder.js.map +2 -2
- package/components/StopsFinder/StopsFinderOption.js +3 -3
- package/components/StopsFinder/StopsFinderOption.js.map +2 -2
- package/components/Zoom/Zoom.js +35 -35
- package/components/Zoom/Zoom.js.map +2 -2
- package/package.json +33 -29
- package/propTypes.js +10 -10
- package/propTypes.js.map +2 -2
- package/utils/GlobalsForOle.js +57 -57
- package/utils/GlobalsForOle.js.map +2 -2
- package/utils/KML.js +32 -32
- package/utils/KML.js.map +2 -2
- package/utils/Styles.js +7 -7
- package/utils/Styles.js.map +2 -2
- package/utils/timeUtils.js +6 -6
- package/utils/timeUtils.js.map +2 -2
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
1
|
import OLMap from "ol/Map";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
4
|
const propTypes = {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
9
|
-
/**
|
|
10
|
-
* The extent to be zoomed.
|
|
6
|
+
* Button content.
|
|
11
7
|
*/
|
|
12
|
-
|
|
8
|
+
children: PropTypes.node.isRequired,
|
|
13
9
|
/**
|
|
14
10
|
* CSS class for the fitExtent button.
|
|
15
11
|
*/
|
|
16
12
|
className: PropTypes.string,
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
14
|
+
* The extent to be zoomed.
|
|
15
|
+
*/
|
|
16
|
+
extent: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
17
|
+
/**
|
|
18
|
+
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
map: PropTypes.instanceOf(OLMap).isRequired
|
|
21
21
|
};
|
|
22
22
|
function FitExtent({
|
|
23
|
-
map,
|
|
24
|
-
extent,
|
|
25
|
-
className = "rs-fit-extent",
|
|
26
23
|
children,
|
|
24
|
+
className = "rs-fit-extent",
|
|
25
|
+
extent,
|
|
26
|
+
map,
|
|
27
27
|
...other
|
|
28
28
|
}) {
|
|
29
29
|
const fit = (evt) => {
|
|
@@ -37,10 +37,10 @@ function FitExtent({
|
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
39
39
|
className,
|
|
40
|
-
role: "button",
|
|
41
|
-
tabIndex: "0",
|
|
42
40
|
onClick: fit,
|
|
43
41
|
onKeyPress: fit,
|
|
42
|
+
role: "button",
|
|
43
|
+
tabIndex: "0",
|
|
44
44
|
...other
|
|
45
45
|
},
|
|
46
46
|
children
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/FitExtent/FitExtent.js"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,
|
|
4
|
+
"sourcesContent": ["import OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\n\nconst propTypes = {\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).isRequired,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n};\n\n/**\n * The FitExtent component creates a button that updates the current extent of\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction FitExtent({\n children,\n className = \"rs-fit-extent\",\n extent,\n map,\n ...other\n}) {\n const fit = (evt) => {\n if (evt.which && evt.which !== 13) {\n return;\n }\n map.getView().cancelAnimations();\n map.getView().fit(extent, map.getSize());\n };\n\n return (\n <div\n className={className}\n onClick={fit}\n onKeyPress={fit}\n role=\"button\"\n tabIndex=\"0\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\n\nexport default FitExtent;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU,KAAK;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AACnC;AAMA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,MAAM,CAAC,QAAQ;AACnB,QAAI,IAAI,SAAS,IAAI,UAAU,IAAI;AACjC;AAAA,IACF;AACA,QAAI,QAAQ,EAAE,iBAAiB;AAC/B,QAAI,QAAQ,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,MAAK;AAAA,MACL,UAAS;AAAA,MAER,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,38 +1,51 @@
|
|
|
1
|
-
import React, { PureComponent } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import OLMap from "ol/Map";
|
|
4
|
-
import { transform } from "ol/proj";
|
|
5
|
-
import Point from "ol/geom/Point";
|
|
6
1
|
import Feature from "ol/Feature";
|
|
2
|
+
import Point from "ol/geom/Point";
|
|
3
|
+
import VectorLayer from "ol/layer/Vector";
|
|
4
|
+
import OLMap from "ol/Map";
|
|
7
5
|
import { unByKey } from "ol/Observable";
|
|
8
|
-
import
|
|
6
|
+
import { transform } from "ol/proj";
|
|
7
|
+
import VectorSource from "ol/source/Vector";
|
|
9
8
|
import Circle from "ol/style/Circle";
|
|
10
9
|
import Fill from "ol/style/Fill";
|
|
11
10
|
import Stroke from "ol/style/Stroke";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import Style from "ol/style/Style";
|
|
12
|
+
import PropTypes from "prop-types";
|
|
13
|
+
import React, { PureComponent } from "react";
|
|
14
14
|
import { FaRegDotCircle } from "react-icons/fa";
|
|
15
15
|
const propTypes = {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* If true, the map will center once on the position then will constantly recenter to the current Position.
|
|
18
|
+
* If false, the map will center once on the position then will never recenter if the position changes.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
alwaysRecenterToPosition: PropTypes.bool,
|
|
20
21
|
/**
|
|
21
22
|
* Children content of the Geolocation button.
|
|
22
23
|
*/
|
|
23
24
|
children: PropTypes.node,
|
|
25
|
+
/**
|
|
26
|
+
* CSS class of the button.
|
|
27
|
+
*/
|
|
28
|
+
className: PropTypes.string,
|
|
29
|
+
/**
|
|
30
|
+
* Color (Number array with rgb values) or style function.
|
|
31
|
+
* If a color is given, the style is animated.
|
|
32
|
+
*/
|
|
33
|
+
colorOrStyleFunc: PropTypes.oneOfType([
|
|
34
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
35
|
+
PropTypes.func
|
|
36
|
+
]),
|
|
24
37
|
/**
|
|
25
38
|
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
26
39
|
*/
|
|
27
40
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
28
41
|
/**
|
|
29
|
-
*
|
|
42
|
+
* If true, the map will never center to the current position
|
|
30
43
|
*/
|
|
31
|
-
|
|
44
|
+
neverCenterToPosition: PropTypes.bool,
|
|
32
45
|
/**
|
|
33
|
-
*
|
|
46
|
+
* If true, the map is not centered after it has been dragged once.
|
|
34
47
|
*/
|
|
35
|
-
|
|
48
|
+
noCenterAfterDrag: PropTypes.bool,
|
|
36
49
|
/**
|
|
37
50
|
* Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.
|
|
38
51
|
*/
|
|
@@ -42,42 +55,29 @@ const propTypes = {
|
|
|
42
55
|
*/
|
|
43
56
|
onDeactivate: PropTypes.func,
|
|
44
57
|
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
noCenterAfterDrag: PropTypes.bool,
|
|
48
|
-
/**
|
|
49
|
-
* If true, the map will center once on the position then will constantly recenter to the current Position.
|
|
50
|
-
* If false, the map will center once on the position then will never recenter if the position changes.
|
|
51
|
-
*/
|
|
52
|
-
alwaysRecenterToPosition: PropTypes.bool,
|
|
53
|
-
/**
|
|
54
|
-
* If true, the map will never center to the current position
|
|
58
|
+
* Function triggered when geolocating is not successful.
|
|
55
59
|
*/
|
|
56
|
-
|
|
60
|
+
onError: PropTypes.func,
|
|
57
61
|
/**
|
|
58
|
-
*
|
|
59
|
-
* If a color is given, the style is animated.
|
|
62
|
+
* Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.
|
|
60
63
|
*/
|
|
61
|
-
|
|
62
|
-
PropTypes.arrayOf(PropTypes.number),
|
|
63
|
-
PropTypes.func
|
|
64
|
-
])
|
|
64
|
+
onSuccess: PropTypes.func
|
|
65
65
|
};
|
|
66
66
|
const defaultProps = {
|
|
67
|
-
|
|
67
|
+
alwaysRecenterToPosition: true,
|
|
68
68
|
children: /* @__PURE__ */ React.createElement(FaRegDotCircle, { focusable: false }),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
className: "rs-geolocation",
|
|
70
|
+
colorOrStyleFunc: [235, 0, 0],
|
|
71
|
+
neverCenterToPosition: false,
|
|
72
|
+
noCenterAfterDrag: false,
|
|
73
73
|
onActivate: () => {
|
|
74
74
|
},
|
|
75
75
|
onDeactivate: () => {
|
|
76
76
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
onError: () => {
|
|
78
|
+
},
|
|
79
|
+
onSuccess: () => {
|
|
80
|
+
}
|
|
81
81
|
};
|
|
82
82
|
class Geolocation extends PureComponent {
|
|
83
83
|
constructor(props) {
|
|
@@ -91,39 +91,6 @@ class Geolocation extends PureComponent {
|
|
|
91
91
|
};
|
|
92
92
|
this.point = void 0;
|
|
93
93
|
}
|
|
94
|
-
componentWillUnmount() {
|
|
95
|
-
this.deactivate();
|
|
96
|
-
}
|
|
97
|
-
toggle() {
|
|
98
|
-
const { active } = this.state;
|
|
99
|
-
const { onError } = this.props;
|
|
100
|
-
const geolocation = "geolocation" in navigator;
|
|
101
|
-
if (!geolocation) {
|
|
102
|
-
onError(new Error("Geolocation not supported"));
|
|
103
|
-
} else if (!active) {
|
|
104
|
-
this.activate();
|
|
105
|
-
} else {
|
|
106
|
-
this.deactivate();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
error(error) {
|
|
110
|
-
const { onError } = this.props;
|
|
111
|
-
this.deactivate();
|
|
112
|
-
onError(error);
|
|
113
|
-
}
|
|
114
|
-
deactivate() {
|
|
115
|
-
const { map, onDeactivate } = this.props;
|
|
116
|
-
window.clearInterval(this.interval);
|
|
117
|
-
this.layer.setMap(null);
|
|
118
|
-
navigator.geolocation.clearWatch(this.watch);
|
|
119
|
-
this.setState({
|
|
120
|
-
active: false
|
|
121
|
-
});
|
|
122
|
-
this.isRecenteringToPosition = true;
|
|
123
|
-
this.point = void 0;
|
|
124
|
-
onDeactivate(map, this);
|
|
125
|
-
unByKey(this.dragListener);
|
|
126
|
-
}
|
|
127
94
|
activate() {
|
|
128
95
|
const { map, noCenterAfterDrag, onActivate } = this.props;
|
|
129
96
|
this.projection = map.getView().getProjection().getCode();
|
|
@@ -145,21 +112,26 @@ class Geolocation extends PureComponent {
|
|
|
145
112
|
}
|
|
146
113
|
onActivate(map, this);
|
|
147
114
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
115
|
+
componentWillUnmount() {
|
|
116
|
+
this.deactivate();
|
|
117
|
+
}
|
|
118
|
+
deactivate() {
|
|
119
|
+
const { map, onDeactivate } = this.props;
|
|
120
|
+
window.clearInterval(this.interval);
|
|
121
|
+
this.layer.setMap(null);
|
|
122
|
+
navigator.geolocation.clearWatch(this.watch);
|
|
123
|
+
this.setState({
|
|
124
|
+
active: false
|
|
125
|
+
});
|
|
126
|
+
this.isRecenteringToPosition = true;
|
|
127
|
+
this.point = void 0;
|
|
128
|
+
onDeactivate(map, this);
|
|
129
|
+
unByKey(this.dragListener);
|
|
130
|
+
}
|
|
131
|
+
error(error) {
|
|
132
|
+
const { onError } = this.props;
|
|
133
|
+
this.deactivate();
|
|
134
|
+
onError(error);
|
|
163
135
|
}
|
|
164
136
|
highlight() {
|
|
165
137
|
const { colorOrStyleFunc } = this.props;
|
|
@@ -184,15 +156,15 @@ class Geolocation extends PureComponent {
|
|
|
184
156
|
feature.setStyle(() => {
|
|
185
157
|
const circleStyle = new Style({
|
|
186
158
|
image: new Circle({
|
|
187
|
-
radius: 20,
|
|
188
|
-
rotation,
|
|
189
159
|
fill: new Fill({
|
|
190
160
|
color: "rgba(255, 255, 255, 0.01)"
|
|
191
161
|
}),
|
|
162
|
+
radius: 20,
|
|
163
|
+
rotation,
|
|
192
164
|
stroke: new Stroke({
|
|
165
|
+
color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,
|
|
193
166
|
lineDash: [30, 10],
|
|
194
|
-
width: 6
|
|
195
|
-
color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`
|
|
167
|
+
width: 6
|
|
196
168
|
})
|
|
197
169
|
})
|
|
198
170
|
});
|
|
@@ -200,10 +172,10 @@ class Geolocation extends PureComponent {
|
|
|
200
172
|
return [
|
|
201
173
|
new Style({
|
|
202
174
|
image: new Circle({
|
|
203
|
-
radius: 10,
|
|
204
175
|
fill: new Fill({
|
|
205
176
|
color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`
|
|
206
|
-
})
|
|
177
|
+
}),
|
|
178
|
+
radius: 10
|
|
207
179
|
})
|
|
208
180
|
}),
|
|
209
181
|
circleStyle
|
|
@@ -224,8 +196,6 @@ class Geolocation extends PureComponent {
|
|
|
224
196
|
return /* @__PURE__ */ React.createElement(
|
|
225
197
|
"div",
|
|
226
198
|
{
|
|
227
|
-
role: "button",
|
|
228
|
-
tabIndex: "0",
|
|
229
199
|
className: `${className} ${active ? "rs-active" : ""}`,
|
|
230
200
|
onClick: () => {
|
|
231
201
|
return this.toggle();
|
|
@@ -233,11 +203,41 @@ class Geolocation extends PureComponent {
|
|
|
233
203
|
onKeyPress: (e) => {
|
|
234
204
|
return e.which === 13 && this.toggle();
|
|
235
205
|
},
|
|
206
|
+
role: "button",
|
|
207
|
+
tabIndex: "0",
|
|
236
208
|
...other
|
|
237
209
|
},
|
|
238
210
|
children
|
|
239
211
|
);
|
|
240
212
|
}
|
|
213
|
+
toggle() {
|
|
214
|
+
const { active } = this.state;
|
|
215
|
+
const { onError } = this.props;
|
|
216
|
+
const geolocation = "geolocation" in navigator;
|
|
217
|
+
if (!geolocation) {
|
|
218
|
+
onError(new Error("Geolocation not supported"));
|
|
219
|
+
} else if (!active) {
|
|
220
|
+
this.activate();
|
|
221
|
+
} else {
|
|
222
|
+
this.deactivate();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
update({ coords: { latitude, longitude } }) {
|
|
226
|
+
const { alwaysRecenterToPosition, map, neverCenterToPosition, onSuccess } = this.props;
|
|
227
|
+
const position = transform(
|
|
228
|
+
[longitude, latitude],
|
|
229
|
+
"EPSG:4326",
|
|
230
|
+
this.projection
|
|
231
|
+
);
|
|
232
|
+
this.point.setCoordinates(position);
|
|
233
|
+
if (!neverCenterToPosition && this.isRecenteringToPosition) {
|
|
234
|
+
map.getView().setCenter(position);
|
|
235
|
+
if (!alwaysRecenterToPosition) {
|
|
236
|
+
this.isRecenteringToPosition = false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
onSuccess(map, [latitude, longitude], this);
|
|
240
|
+
}
|
|
241
241
|
}
|
|
242
242
|
Geolocation.propTypes = propTypes;
|
|
243
243
|
Geolocation.defaultProps = defaultProps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Geolocation/Geolocation.js"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,OAAO,
|
|
4
|
+
"sourcesContent": ["import Feature from \"ol/Feature\";\nimport Point from \"ol/geom/Point\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { transform } from \"ol/proj\";\nimport VectorSource from \"ol/source/Vector\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\nimport { FaRegDotCircle } from \"react-icons/fa\";\n\nconst propTypes = {\n /**\n * If true, the map will center once on the position then will constantly recenter to the current Position.\n * If false, the map will center once on the position then will never recenter if the position changes.\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * If true, the map will never center to the current position\n */\n neverCenterToPosition: PropTypes.bool,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n};\n\nconst defaultProps = {\n alwaysRecenterToPosition: true,\n children: <FaRegDotCircle focusable={false} />,\n className: \"rs-geolocation\",\n colorOrStyleFunc: [235, 0, 0],\n neverCenterToPosition: false,\n noCenterAfterDrag: false,\n onActivate: () => {},\n onDeactivate: () => {},\n onError: () => {},\n onSuccess: () => {},\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on(\"pointerdrag\", () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n error(error) {\n const { onError } = this.props;\n\n this.deactivate();\n onError(error);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n fill: new Fill({\n color: \"rgba(255, 255, 255, 0.01)\",\n }),\n radius: 20,\n rotation,\n stroke: new Stroke({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n lineDash: [30, 10],\n width: 6,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n radius: 10,\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n className={`${className} ${active ? \"rs-active\" : \"\"}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n role=\"button\"\n tabIndex=\"0\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = \"geolocation\" in navigator;\n\n if (!geolocation) {\n onError(new Error(\"Geolocation not supported\"));\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n update({ coords: { latitude, longitude } }) {\n const { alwaysRecenterToPosition, map, neverCenterToPosition, onSuccess } =\n this.props;\n\n const position = transform(\n [longitude, latitude],\n \"EPSG:4326\",\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (!neverCenterToPosition && this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,kBAAkB;AACzB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AACrC,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhB,0BAA0B,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpC,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,kBAAkB,UAAU,UAAU;AAAA,IACpC,UAAU,QAAQ,UAAU,MA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