react-spatial 1.2.2 → 1.2.3-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/LayerService.js +128 -184
  2. package/LayerService.js.map +7 -1
  3. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +163 -221
  4. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
  5. package/components/BaseLayerSwitcher/index.js +1 -3
  6. package/components/BaseLayerSwitcher/index.js.map +7 -1
  7. package/components/BasicMap/BasicMap.js +147 -285
  8. package/components/BasicMap/BasicMap.js.map +7 -1
  9. package/components/BasicMap/index.js +1 -3
  10. package/components/BasicMap/index.js.map +7 -1
  11. package/components/CanvasSaveButton/CanvasSaveButton.js +165 -419
  12. package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
  13. package/components/CanvasSaveButton/index.js +1 -3
  14. package/components/CanvasSaveButton/index.js.map +7 -1
  15. package/components/Copyright/Copyright.js +29 -70
  16. package/components/Copyright/Copyright.js.map +7 -1
  17. package/components/Copyright/index.js +1 -3
  18. package/components/Copyright/index.js.map +7 -1
  19. package/components/FeatureExportButton/FeatureExportButton.js +40 -106
  20. package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
  21. package/components/FeatureExportButton/index.js +1 -3
  22. package/components/FeatureExportButton/index.js.map +7 -1
  23. package/components/FilterButton/FilterButton.js +41 -106
  24. package/components/FilterButton/FilterButton.js.map +7 -1
  25. package/components/FilterButton/index.js +1 -3
  26. package/components/FilterButton/index.js.map +7 -1
  27. package/components/FitExtent/FitExtent.js +17 -50
  28. package/components/FitExtent/FitExtent.js.map +7 -1
  29. package/components/FitExtent/index.js +1 -3
  30. package/components/FitExtent/index.js.map +7 -1
  31. package/components/FollowButton/FollowButton.js +41 -111
  32. package/components/FollowButton/FollowButton.js.map +7 -1
  33. package/components/FollowButton/index.js +1 -3
  34. package/components/FollowButton/index.js.map +7 -1
  35. package/components/Geolocation/Geolocation.js +104 -213
  36. package/components/Geolocation/Geolocation.js.map +7 -1
  37. package/components/Geolocation/index.js +1 -3
  38. package/components/Geolocation/index.js.map +7 -1
  39. package/components/LayerTree/LayerTree.js +204 -410
  40. package/components/LayerTree/LayerTree.js.map +7 -1
  41. package/components/LayerTree/index.js +1 -3
  42. package/components/LayerTree/index.js.map +7 -1
  43. package/components/MousePosition/MousePosition.js +61 -130
  44. package/components/MousePosition/MousePosition.js.map +7 -1
  45. package/components/MousePosition/index.js +1 -3
  46. package/components/MousePosition/index.js.map +7 -1
  47. package/components/NorthArrow/NorthArrow.js +22 -62
  48. package/components/NorthArrow/NorthArrow.js.map +7 -1
  49. package/components/NorthArrow/index.js +1 -3
  50. package/components/NorthArrow/index.js.map +7 -1
  51. package/components/Overlay/Overlay.js +83 -130
  52. package/components/Overlay/Overlay.js.map +7 -1
  53. package/components/Overlay/index.js +1 -3
  54. package/components/Overlay/index.js.map +7 -1
  55. package/components/Permalink/Permalink.js +150 -244
  56. package/components/Permalink/Permalink.js.map +7 -1
  57. package/components/Permalink/index.js +1 -3
  58. package/components/Permalink/index.js.map +7 -1
  59. package/components/Popup/Popup.js +106 -233
  60. package/components/Popup/Popup.js.map +7 -1
  61. package/components/Popup/index.js +1 -3
  62. package/components/Popup/index.js.map +7 -1
  63. package/components/ResizeHandler/ResizeHandler.js +58 -113
  64. package/components/ResizeHandler/ResizeHandler.js.map +7 -1
  65. package/components/ResizeHandler/index.js +1 -3
  66. package/components/ResizeHandler/index.js.map +7 -1
  67. package/components/RouteSchedule/RouteSchedule.js +150 -283
  68. package/components/RouteSchedule/RouteSchedule.js.map +7 -1
  69. package/components/RouteSchedule/index.js +1 -3
  70. package/components/RouteSchedule/index.js.map +7 -1
  71. package/components/ScaleLine/ScaleLine.js +21 -45
  72. package/components/ScaleLine/ScaleLine.js.map +7 -1
  73. package/components/ScaleLine/index.js +1 -3
  74. package/components/ScaleLine/index.js.map +7 -1
  75. package/components/Search/Search.js +122 -186
  76. package/components/Search/Search.js.map +7 -1
  77. package/components/Search/SearchService.js +45 -69
  78. package/components/Search/SearchService.js.map +7 -1
  79. package/components/Search/engines/Engine.js +18 -25
  80. package/components/Search/engines/Engine.js.map +7 -1
  81. package/components/Search/engines/StopFinder.js +21 -38
  82. package/components/Search/engines/StopFinder.js.map +7 -1
  83. package/components/Search/index.js +3 -6
  84. package/components/Search/index.js.map +7 -1
  85. package/components/StopsFinder/StopsFinder.js +123 -174
  86. package/components/StopsFinder/StopsFinder.js.map +7 -1
  87. package/components/StopsFinder/StopsFinderOption.js +37 -54
  88. package/components/StopsFinder/StopsFinderOption.js.map +7 -1
  89. package/components/StopsFinder/index.js +1 -3
  90. package/components/StopsFinder/index.js.map +7 -1
  91. package/components/TrackerControl/TrackerControl.js +73 -128
  92. package/components/TrackerControl/TrackerControl.js.map +7 -1
  93. package/components/TrackerControl/index.js +1 -3
  94. package/components/TrackerControl/index.js.map +7 -1
  95. package/components/Zoom/Zoom.js +69 -112
  96. package/components/Zoom/Zoom.js.map +7 -1
  97. package/components/Zoom/index.js +1 -3
  98. package/components/Zoom/index.js.map +7 -1
  99. package/package.json +10 -5
  100. package/propTypes.js +17 -23
  101. package/propTypes.js.map +7 -1
  102. package/setupTests.js +2 -4
  103. package/setupTests.js.map +7 -1
  104. package/themes/README.md +26 -0
  105. package/themes/default/components.scss +0 -1
  106. package/themes/default/examples.scss +0 -1
  107. package/utils/GlobalsForOle.js +63 -64
  108. package/utils/GlobalsForOle.js.map +7 -1
  109. package/utils/KML.js +178 -364
  110. package/utils/KML.js.map +7 -1
  111. package/utils/KMLFormat.js +37 -73
  112. package/utils/KMLFormat.js.map +7 -1
  113. package/utils/Styles.js +24 -32
  114. package/utils/Styles.js.map +7 -1
  115. package/utils/getPolygonPattern.js +11 -44
  116. package/utils/getPolygonPattern.js.map +7 -1
  117. package/utils/timeUtils.js +16 -35
  118. package/utils/timeUtils.js.map +7 -1
  119. package/LayerService.test.js +0 -160
  120. package/LayerService.test.js.map +0 -1
  121. package/Projections.js +0 -16
  122. package/Projections.js.map +0 -1
  123. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
  124. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
  125. package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
  126. package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
  127. package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
  128. package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
  129. package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
  130. package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
  131. package/components/BaseLayerToggler/index.js +0 -3
  132. package/components/BaseLayerToggler/index.js.map +0 -1
  133. package/components/BasicMap/BasicMap.test.js +0 -288
  134. package/components/BasicMap/BasicMap.test.js.map +0 -1
  135. package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
  136. package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
  137. package/components/Copyright/Copyright.test.js +0 -133
  138. package/components/Copyright/Copyright.test.js.map +0 -1
  139. package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
  140. package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
  141. package/components/FilterButton/FilterButton.test.js +0 -48
  142. package/components/FilterButton/FilterButton.test.js.map +0 -1
  143. package/components/FitExtent/FitExtent.test.js +0 -44
  144. package/components/FitExtent/FitExtent.test.js.map +0 -1
  145. package/components/FollowButton/FollowButton.test.js +0 -57
  146. package/components/FollowButton/FollowButton.test.js.map +0 -1
  147. package/components/Geolocation/Geolocation.test.js +0 -263
  148. package/components/Geolocation/Geolocation.test.js.map +0 -1
  149. package/components/LayerTree/LayerTree.test.js +0 -323
  150. package/components/LayerTree/LayerTree.test.js.map +0 -1
  151. package/components/MousePosition/MousePosition.test.js +0 -125
  152. package/components/MousePosition/MousePosition.test.js.map +0 -1
  153. package/components/NorthArrow/NorthArrow.test.js +0 -106
  154. package/components/NorthArrow/NorthArrow.test.js.map +0 -1
  155. package/components/Overlay/Overlay.test.js +0 -145
  156. package/components/Overlay/Overlay.test.js.map +0 -1
  157. package/components/Permalink/Permalink.test.js +0 -267
  158. package/components/Permalink/Permalink.test.js.map +0 -1
  159. package/components/Popup/Popup.test.js +0 -291
  160. package/components/Popup/Popup.test.js.map +0 -1
  161. package/components/ResizeHandler/ResizeHandler.test.js +0 -410
  162. package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
  163. package/components/RouteSchedule/RouteSchedule.test.js +0 -102
  164. package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
  165. package/components/ScaleLine/ScaleLine.test.js +0 -32
  166. package/components/ScaleLine/ScaleLine.test.js.map +0 -1
  167. package/components/Search/Search.test.js +0 -15
  168. package/components/Search/Search.test.js.map +0 -1
  169. package/components/StopsFinder/StopsFinder.test.js +0 -19
  170. package/components/StopsFinder/StopsFinder.test.js.map +0 -1
  171. package/components/TrackerControl/TrackerControl.test.js +0 -17
  172. package/components/TrackerControl/TrackerControl.test.js.map +0 -1
  173. package/components/Zoom/Zoom.test.js +0 -150
  174. package/components/Zoom/Zoom.test.js.map +0 -1
  175. package/styleguidist/ComponentsList.js +0 -52
  176. package/styleguidist/ComponentsList.js.map +0 -1
  177. package/styleguidist/StyleGuide.js +0 -253
  178. package/styleguidist/StyleGuide.js.map +0 -1
  179. package/utils/KML.test.js +0 -163
  180. package/utils/KML.test.js.map +0 -1
  181. package/utils/KMLFormat.test.js +0 -22
  182. package/utils/KMLFormat.test.js.map +0 -1
  183. package/utils/getPolygonPattern.test.js +0 -66
  184. package/utils/getPolygonPattern.test.js.map +0 -1
  185. package/utils/timeUtils.test.js +0 -32
  186. package/utils/timeUtils.test.js.map +0 -1
@@ -1,124 +1,68 @@
1
- import React, { PureComponent } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import OLMap from 'ol/Map';
5
- import { transform } from 'ol/proj';
6
- import Point from 'ol/geom/Point';
7
- import Feature from 'ol/Feature';
8
- import { unByKey } from 'ol/Observable';
9
-
10
- import Style from 'ol/style/Style';
11
- import Circle from 'ol/style/Circle';
12
- import Fill from 'ol/style/Fill';
13
- import Stroke from 'ol/style/Stroke';
14
-
15
- import VectorLayer from 'ol/layer/Vector';
16
- import VectorSource from 'ol/source/Vector';
17
-
18
- import { FaRegDotCircle } from 'react-icons/fa';
19
-
20
- var propTypes = {
21
- /**
22
- * CSS class of the button.
23
- */
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
+ import Feature from "ol/Feature";
7
+ import { unByKey } from "ol/Observable";
8
+ import Style from "ol/style/Style";
9
+ import Circle from "ol/style/Circle";
10
+ import Fill from "ol/style/Fill";
11
+ import Stroke from "ol/style/Stroke";
12
+ import VectorLayer from "ol/layer/Vector";
13
+ import VectorSource from "ol/source/Vector";
14
+ import { FaRegDotCircle } from "react-icons/fa";
15
+ const propTypes = {
24
16
  className: PropTypes.string,
25
-
26
- /**
27
- * Children content of the Geolocation button.
28
- */
29
17
  children: PropTypes.node,
30
-
31
- /**
32
- * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
33
- */
34
18
  map: PropTypes.instanceOf(OLMap).isRequired,
35
-
36
- /**
37
- * Function triggered when geolocating is not successful.
38
- */
39
19
  onError: PropTypes.func,
40
-
41
- /**
42
- * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.
43
- */
44
20
  onSuccess: PropTypes.func,
45
-
46
- /**
47
- * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.
48
- */
49
21
  onActivate: PropTypes.func,
50
-
51
- /**
52
- * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..
53
- */
54
22
  onDeactivate: PropTypes.func,
55
-
56
- /**
57
- * If true, the map is not centered after it has been dragged once.
58
- */
59
23
  noCenterAfterDrag: PropTypes.bool,
60
-
61
- /**
62
- * If true, the map will constantly recenter to the current Position
63
- */
64
24
  alwaysRecenterToPosition: PropTypes.bool,
65
-
66
- /**
67
- * Color (Number array with rgb values) or style function.
68
- * If a color is given, the style is animated.
69
- */
70
25
  colorOrStyleFunc: PropTypes.oneOfType([
71
26
  PropTypes.arrayOf(PropTypes.number),
72
- PropTypes.func ]),
27
+ PropTypes.func
28
+ ])
73
29
  };
74
-
75
- var defaultProps = {
76
- className: 'rs-geolocation',
77
- children: React.createElement( FaRegDotCircle, { focusable: false }),
78
- onError: function () {},
79
- onSuccess: function () {},
80
- onActivate: function () {},
81
- onDeactivate: function () {},
30
+ const defaultProps = {
31
+ className: "rs-geolocation",
32
+ children: /* @__PURE__ */ React.createElement(FaRegDotCircle, {
33
+ focusable: false
34
+ }),
35
+ onError: () => {
36
+ },
37
+ onSuccess: () => {
38
+ },
39
+ onActivate: () => {
40
+ },
41
+ onDeactivate: () => {
42
+ },
82
43
  noCenterAfterDrag: false,
83
44
  alwaysRecenterToPosition: true,
84
- colorOrStyleFunc: [235, 0, 0],
45
+ colorOrStyleFunc: [235, 0, 0]
85
46
  };
86
-
87
- /**
88
- * The GeoLocation component creates a button to display the current device's location on an
89
- * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
90
- */
91
- var Geolocation = /*@__PURE__*/(function (PureComponent) {
92
- function Geolocation(props) {
93
- PureComponent.call(this, props);
94
-
47
+ class Geolocation extends PureComponent {
48
+ constructor(props) {
49
+ super(props);
95
50
  this.layer = new VectorLayer({
96
- source: new VectorSource(),
51
+ source: new VectorSource()
97
52
  });
98
-
99
53
  this.isRecenteringToPosition = true;
100
-
101
54
  this.state = {
102
- active: false,
55
+ active: false
103
56
  };
104
- this.point = undefined;
57
+ this.point = void 0;
105
58
  }
106
-
107
- if ( PureComponent ) Geolocation.__proto__ = PureComponent;
108
- Geolocation.prototype = Object.create( PureComponent && PureComponent.prototype );
109
- Geolocation.prototype.constructor = Geolocation;
110
-
111
- Geolocation.prototype.componentWillUnmount = function componentWillUnmount () {
59
+ componentWillUnmount() {
112
60
  this.deactivate();
113
- };
114
-
115
- Geolocation.prototype.toggle = function toggle () {
116
- var ref = this.state;
117
- var active = ref.active;
118
- var ref$1 = this.props;
119
- var onError = ref$1.onError;
120
- var geolocation = 'geolocation' in navigator;
121
-
61
+ }
62
+ toggle() {
63
+ const { active } = this.state;
64
+ const { onError } = this.props;
65
+ const geolocation = "geolocation" in navigator;
122
66
  if (!geolocation) {
123
67
  onError();
124
68
  } else if (!active) {
@@ -126,108 +70,74 @@ var Geolocation = /*@__PURE__*/(function (PureComponent) {
126
70
  } else {
127
71
  this.deactivate();
128
72
  }
129
- };
130
-
131
- Geolocation.prototype.error = function error () {
132
- var ref = this.props;
133
- var onError = ref.onError;
134
-
73
+ }
74
+ error() {
75
+ const { onError } = this.props;
135
76
  this.deactivate();
136
77
  onError();
137
- };
138
-
139
- Geolocation.prototype.deactivate = function deactivate () {
140
- var ref = this.props;
141
- var map = ref.map;
142
- var onDeactivate = ref.onDeactivate;
78
+ }
79
+ deactivate() {
80
+ const { map, onDeactivate } = this.props;
143
81
  window.clearInterval(this.interval);
144
82
  this.layer.setMap(null);
145
83
  navigator.geolocation.clearWatch(this.watch);
146
-
147
84
  this.setState({
148
- active: false,
85
+ active: false
149
86
  });
150
-
151
87
  this.isRecenteringToPosition = true;
152
- this.point = undefined;
88
+ this.point = void 0;
153
89
  onDeactivate(map, this);
154
90
  unByKey(this.dragListener);
155
- };
156
-
157
- Geolocation.prototype.activate = function activate () {
158
- var this$1 = this;
159
-
160
- var ref = this.props;
161
- var map = ref.map;
162
- var noCenterAfterDrag = ref.noCenterAfterDrag;
163
- var onActivate = ref.onActivate;
164
-
91
+ }
92
+ activate() {
93
+ const { map, noCenterAfterDrag, onActivate } = this.props;
165
94
  this.projection = map.getView().getProjection().getCode();
166
95
  this.point = new Point([0, 0]);
167
96
  this.highlight();
168
97
  this.layer.setMap(map);
169
98
  this.setState({ active: true });
170
-
171
99
  this.watch = navigator.geolocation.watchPosition(
172
100
  this.update.bind(this),
173
101
  this.error.bind(this),
174
102
  {
175
- enableHighAccuracy: true,
103
+ enableHighAccuracy: true
176
104
  }
177
105
  );
178
-
179
106
  if (noCenterAfterDrag) {
180
- this.dragListener = map.on('pointerdrag', function () {
181
- this$1.isRecenteringToPosition = false;
107
+ this.dragListener = map.on("pointerdrag", () => {
108
+ this.isRecenteringToPosition = false;
182
109
  });
183
110
  }
184
-
185
111
  onActivate(map, this);
186
- };
187
-
188
- Geolocation.prototype.update = function update (ref) {
189
- var ref_coords = ref.coords;
190
- var latitude = ref_coords.latitude;
191
- var longitude = ref_coords.longitude;
192
-
193
- var ref$1 = this.props;
194
- var map = ref$1.map;
195
- var alwaysRecenterToPosition = ref$1.alwaysRecenterToPosition;
196
- var onSuccess = ref$1.onSuccess;
197
-
198
- var position = transform(
112
+ }
113
+ update({ coords: { latitude, longitude } }) {
114
+ const { map, alwaysRecenterToPosition, onSuccess } = this.props;
115
+ const position = transform(
199
116
  [longitude, latitude],
200
- 'EPSG:4326',
117
+ "EPSG:4326",
201
118
  this.projection
202
119
  );
203
120
  this.point.setCoordinates(position);
204
-
205
121
  if (this.isRecenteringToPosition) {
206
122
  map.getView().setCenter(position);
207
123
  if (!alwaysRecenterToPosition) {
208
124
  this.isRecenteringToPosition = false;
209
125
  }
210
126
  }
211
-
212
127
  onSuccess(map, [latitude, longitude], this);
213
- };
214
-
215
- Geolocation.prototype.highlight = function highlight () {
216
- var ref = this.props;
217
- var colorOrStyleFunc = ref.colorOrStyleFunc;
218
- var feature = new Feature({
219
- geometry: this.point,
128
+ }
129
+ highlight() {
130
+ const { colorOrStyleFunc } = this.props;
131
+ const feature = new Feature({
132
+ geometry: this.point
220
133
  });
221
-
222
134
  if (Array.isArray(colorOrStyleFunc)) {
223
- var color = colorOrStyleFunc;
224
-
225
- var decrease = true;
226
- var opacity = 0.5;
227
- var rotation = 0;
228
-
135
+ const color = colorOrStyleFunc;
136
+ let decrease = true;
137
+ let opacity = 0.5;
138
+ let rotation = 0;
229
139
  window.clearInterval(this.interval);
230
- this.interval = window.setInterval(function () {
140
+ this.interval = window.setInterval(() => {
231
141
  rotation += 0.03;
232
142
  decrease = opacity < 0.1 ? false : decrease;
233
143
  decrease = opacity > 0.5 ? true : decrease;
@@ -236,79 +146,60 @@ var Geolocation = /*@__PURE__*/(function (PureComponent) {
236
146
  feature.changed();
237
147
  }
238
148
  }, 50);
239
-
240
- feature.setStyle(function () {
241
- var circleStyle = new Style({
149
+ feature.setStyle(() => {
150
+ const circleStyle = new Style({
242
151
  image: new Circle({
243
152
  radius: 20,
244
- rotation: rotation,
153
+ rotation,
245
154
  fill: new Fill({
246
- color: 'rgba(255, 255, 255, 0.01)',
155
+ color: "rgba(255, 255, 255, 0.01)"
247
156
  }),
248
157
  stroke: new Stroke({
249
158
  lineDash: [30, 10],
250
159
  width: 6,
251
- color: ("rgba(" + (color[0]) + ", " + (color[1]) + ", " + (color[2]) + ", " + opacity + ")"),
252
- }),
253
- }),
160
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`
161
+ })
162
+ })
254
163
  });
255
-
256
164
  circleStyle.getImage().setRotation(rotation);
257
-
258
165
  return [
259
166
  new Style({
260
167
  image: new Circle({
261
168
  radius: 10,
262
169
  fill: new Fill({
263
- color: ("rgba(" + (color[0]) + ", " + (color[1]) + ", " + (color[2]) + ", 0.5)"),
264
- }),
265
- }),
170
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`
171
+ })
172
+ })
266
173
  }),
267
- circleStyle ];
174
+ circleStyle
175
+ ];
268
176
  });
269
177
  } else {
270
178
  feature.setStyle(colorOrStyleFunc);
271
179
  }
272
-
273
180
  this.layer.getSource().clear();
274
181
  this.layer.getSource().addFeature(feature);
275
- };
276
-
277
- Geolocation.prototype.render = function render () {
278
- var this$1 = this;
279
-
280
- var ref = this.props;
281
- var children = ref.children;
282
- var className = ref.className;
283
- // Remove component props from other HTML props.
284
- var other = Object.entries(this.props).reduce(function (props, ref) {
285
- var obj;
286
-
287
- var key = ref[0];
288
- var value = ref[1];
289
- return propTypes[key] ? props : Object.assign({}, props, ( obj = {}, obj[key] = value, obj ));
182
+ }
183
+ render() {
184
+ const { children, className } = this.props;
185
+ const other = Object.entries(this.props).reduce((props, [key, value]) => {
186
+ return propTypes[key] ? props : { ...props, [key]: value };
290
187
  }, {});
291
- var ref$1 = this.state;
292
- var active = ref$1.active;
293
-
294
- return (
295
- React.createElement( 'div', Object.assign({},
296
- { role: "button", tabIndex: "0", className: (className + " " + (active ? 'rs-active' : '')), onClick: function () {
297
- return this$1.toggle();
298
- }, onKeyPress: function (e) {
299
- return e.which === 13 && this$1.toggle();
300
- } }, other),
301
- children
302
- )
303
- );
304
- };
305
-
306
- return Geolocation;
307
- }(PureComponent));
308
-
188
+ const { active } = this.state;
189
+ return /* @__PURE__ */ React.createElement("div", {
190
+ role: "button",
191
+ tabIndex: "0",
192
+ className: `${className} ${active ? "rs-active" : ""}`,
193
+ onClick: () => {
194
+ return this.toggle();
195
+ },
196
+ onKeyPress: (e) => {
197
+ return e.which === 13 && this.toggle();
198
+ },
199
+ ...other
200
+ }, children);
201
+ }
202
+ }
309
203
  Geolocation.propTypes = propTypes;
310
204
  Geolocation.defaultProps = defaultProps;
311
-
312
205
  export default Geolocation;
313
-
314
- //# sourceMappingURL=Geolocation.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"Geolocation.js","sources":["../../../src/components/Geolocation/Geolocation.js"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport OLMap from 'ol/Map';\nimport { transform } from 'ol/proj';\nimport Point from 'ol/geom/Point';\nimport Feature from 'ol/Feature';\nimport { unByKey } from 'ol/Observable';\n\nimport Style from 'ol/style/Style';\nimport Circle from 'ol/style/Circle';\nimport Fill from 'ol/style/Fill';\nimport Stroke from 'ol/style/Stroke';\n\nimport VectorLayer from 'ol/layer/Vector';\nimport VectorSource from 'ol/source/Vector';\n\nimport { FaRegDotCircle } from 'react-icons/fa';\n\nconst propTypes = {\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * If true, the map will constantly recenter to the current Position\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\n};\n\nconst defaultProps = {\n className: 'rs-geolocation',\n children: <FaRegDotCircle focusable={false} />,\n onError: () => {},\n onSuccess: () => {},\n onActivate: () => {},\n onDeactivate: () => {},\n noCenterAfterDrag: false,\n alwaysRecenterToPosition: true,\n colorOrStyleFunc: [235, 0, 0],\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = 'geolocation' in navigator;\n\n if (!geolocation) {\n onError();\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n error() {\n const { onError } = this.props;\n\n this.deactivate();\n onError();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on('pointerdrag', () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n update({ coords: { latitude, longitude } }) {\n const { map, alwaysRecenterToPosition, onSuccess } = this.props;\n\n const position = transform(\n [longitude, latitude],\n 'EPSG:4326',\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n radius: 20,\n rotation,\n fill: new Fill({\n color: 'rgba(255, 255, 255, 0.01)',\n }),\n stroke: new Stroke({\n lineDash: [30, 10],\n width: 6,\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n radius: 10,\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n role=\"button\"\n tabIndex=\"0\"\n className={`${className} ${active ? 'rs-active' : ''}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],"names":["const","super","this","let"],"mappings":"AAAA,OAAO,KAAK,IAAI,aAAa,QAAQ,OAAO,CAAC;AAC7C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC;AACA,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,SAAS,SAAS,QAAQ,SAAS,CAAC;AACpC,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,SAAS,OAAO,QAAQ,eAAe,CAAC;AACxC;AACA,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAi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AyB;AAC/C;AACA,IAAIA,GAAK,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,UAAC,CAAC,KAAK,KAAc,EAAK;;AAAhB;uBAAK;yBAAY;AAC9E,MAAM,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,kBAAK,KAAK,iBAAE,CAAC,GAAG,IAAG,aAAO,CAAC;AACjE,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,aAAoB,GAAG,IAAI,CAAC;IAAhB,0BAAsB;AAClC;AACA,IAAI,OAAO;AACX,MAAM,sBAAC,uBAAG;AACV,UAAQ,MAAK,QAAQ,EACb,UAAS,GAAG,EACZ,YAAc,SAAS,UAAI,MAAM,GAAG,WAAW,GAAG,IAAK,EACvD,kBAAS,GAAM;AACvB,UAAU,OAAOE,MAAI,CAAC,MAAM,EAAE,CAAC;AAC/B,SAAU,EACF,qBAAY,CAAC,CAAC,EAAK;AAC3B,UAAU,OAAO,CAAC,CAAC,KAAK,KAAK,EAAE,IAAIA,MAAI,CAAC,MAAM,EAAE,CAAC;AACjD,WAAU,EAEE,OACL;AACP,QAAS,QAAS;AAClB,MAAM,CAAM;AACZ,KAAK,CAAC;AACN;;;EA9L0B,gBA+LzB;AACD;AACA,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;AAClC,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC;AACxC;AACA,eAAe,WAAW,CAAC;"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Geolocation/Geolocation.js"],
4
+ "sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport OLMap from 'ol/Map';\nimport { transform } from 'ol/proj';\nimport Point from 'ol/geom/Point';\nimport Feature from 'ol/Feature';\nimport { unByKey } from 'ol/Observable';\n\nimport Style from 'ol/style/Style';\nimport Circle from 'ol/style/Circle';\nimport Fill from 'ol/style/Fill';\nimport Stroke from 'ol/style/Stroke';\n\nimport VectorLayer from 'ol/layer/Vector';\nimport VectorSource from 'ol/source/Vector';\n\nimport { FaRegDotCircle } from 'react-icons/fa';\n\nconst propTypes = {\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * If true, the map will constantly recenter to the current Position\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\n};\n\nconst defaultProps = {\n className: 'rs-geolocation',\n children: <FaRegDotCircle focusable={false} />,\n onError: () => {},\n onSuccess: () => {},\n onActivate: () => {},\n onDeactivate: () => {},\n noCenterAfterDrag: false,\n alwaysRecenterToPosition: true,\n colorOrStyleFunc: [235, 0, 0],\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = 'geolocation' in navigator;\n\n if (!geolocation) {\n onError();\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n error() {\n const { onError } = this.props;\n\n this.deactivate();\n onError();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on('pointerdrag', () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n update({ coords: { latitude, longitude } }) {\n const { map, alwaysRecenterToPosition, onSuccess } = this.props;\n\n const position = transform(\n [longitude, latitude],\n 'EPSG:4326',\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n radius: 20,\n rotation,\n fill: new Fill({\n color: 'rgba(255, 255, 255, 0.01)',\n }),\n stroke: new Stroke({\n lineDash: [30, 10],\n width: 6,\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n radius: 10,\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n role=\"button\"\n tabIndex=\"0\"\n className={`${className} ${active ? 'rs-active' : ''}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AAEtB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAClB,OAAO,aAAa;AACpB,SAAS,eAAe;AAExB,OAAO,WAAW;AAClB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AAEnB,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AAEzB,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA,EAIhB,WAAW,UAAU;AAAA,EAKrB,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AAM;AAAA,cACjD,CAAC;AAAA,YACH,CAAC;AAAA,UACH,CAAC;AAAA,UACD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,cAAQ,SAAS,gBAAgB;AAAA,IACnC;AAEA,SAAK,MAAM,UAAU,EAAE,MAAM;AAC7B,SAAK,MAAM,UAAU,EAAE,WAAW,OAAO;AAAA,EAC3C;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,UAAU,IAAI,KAAK;AAErC,UAAM,QAAQ,OAAO,QAAQ,KAAK,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM;AACvE,aAAO,UAAU,OAAO,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,MAAM;AAAA,IAC3D,GAAG,CAAC,CAAC;AACL,UAAM,EAAE,OAAO,IAAI,KAAK;AAExB,WACE,oCAAC;AAAA,MACC,MAAK;AAAA,MACL,UAAS;AAAA,MACT,WAAW,GAAG,aAAa,SAAS,cAAc;AAAA,MAClD,SAAS,MAAM;AACb,eAAO,KAAK,OAAO;AAAA,MACrB;AAAA,MACA,YAAY,CAAC,MAAM;AACjB,eAAO,EAAE,UAAU,MAAM,KAAK,OAAO;AAAA,MACvC;AAAA,MAEC,GAAG;AAAA,OAEH,QACH;AAAA,EAEJ;AACF;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAE3B,eAAe;",
6
+ "names": []
7
+ }
@@ -1,3 +1 @@
1
- export { default } from './Geolocation';
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export { default } from "./Geolocation";
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Geolocation/index.js"],"sourcesContent":["export { default } from './Geolocation';\n"],"names":[],"mappings":"AAAA,SAAS,OAAO,QAAQ,eAAe,CAAC;"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Geolocation/index.js"],
4
+ "sourcesContent": ["export { default } from './Geolocation';\n"],
5
+ "mappings": "AAAA,wBAAwB;",
6
+ "names": []
7
+ }