react-spatial 2.0.0-beta.0 → 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.
Files changed (124) hide show
  1. package/README.md +5 -10
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +188 -107
  3. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +2 -2
  4. package/components/BaseLayerSwitcher/BaseLayerSwitcher.scss +6 -5
  5. package/components/BaseLayerSwitcher/index.js.map +2 -2
  6. package/components/BasicMap/BasicMap.js +116 -98
  7. package/components/BasicMap/BasicMap.js.map +2 -2
  8. package/components/BasicMap/index.js.map +2 -2
  9. package/components/CanvasSaveButton/CanvasSaveButton.js +448 -316
  10. package/components/CanvasSaveButton/CanvasSaveButton.js.map +2 -2
  11. package/components/CanvasSaveButton/CanvasSaveButton.md.scss +1 -1
  12. package/components/CanvasSaveButton/index.js.map +2 -2
  13. package/components/Copyright/Copyright.js +43 -35
  14. package/components/Copyright/Copyright.js.map +2 -2
  15. package/components/Copyright/index.js.map +2 -2
  16. package/components/FeatureExportButton/FeatureExportButton.js +35 -17
  17. package/components/FeatureExportButton/FeatureExportButton.js.map +2 -2
  18. package/components/FeatureExportButton/index.js.map +2 -2
  19. package/components/FitExtent/FitExtent.js +36 -18
  20. package/components/FitExtent/FitExtent.js.map +2 -2
  21. package/components/FitExtent/index.js.map +2 -2
  22. package/components/Geolocation/Geolocation.js +131 -92
  23. package/components/Geolocation/Geolocation.js.map +2 -2
  24. package/components/Geolocation/Geolocation.scss +7 -5
  25. package/components/Geolocation/index.js.map +2 -2
  26. package/components/LayerTree/LayerTree.js +361 -169
  27. package/components/LayerTree/LayerTree.js.map +2 -2
  28. package/components/LayerTree/LayerTree.scss +4 -6
  29. package/components/LayerTree/index.js.map +2 -2
  30. package/components/MousePosition/MousePosition.js +64 -33
  31. package/components/MousePosition/MousePosition.js.map +2 -2
  32. package/components/MousePosition/index.js.map +2 -2
  33. package/components/NorthArrow/NorthArrow.js +35 -19
  34. package/components/NorthArrow/NorthArrow.js.map +2 -2
  35. package/components/NorthArrow/index.js.map +2 -2
  36. package/components/Overlay/Overlay.js +100 -83
  37. package/components/Overlay/Overlay.js.map +2 -2
  38. package/components/Overlay/index.js.map +2 -2
  39. package/components/Permalink/Permalink.js +135 -90
  40. package/components/Permalink/Permalink.js.map +2 -2
  41. package/components/Permalink/index.js.map +2 -2
  42. package/components/Popup/Popup.js +134 -83
  43. package/components/Popup/Popup.js.map +2 -2
  44. package/components/Popup/Popup.md.scss +1 -0
  45. package/components/Popup/Popup.scss +3 -1
  46. package/components/Popup/index.js.map +2 -2
  47. package/components/ResizeHandler/ResizeHandler.js +51 -45
  48. package/components/ResizeHandler/ResizeHandler.js.map +2 -2
  49. package/components/ResizeHandler/index.js.map +2 -2
  50. package/components/RouteSchedule/RouteSchedule.js +218 -136
  51. package/components/RouteSchedule/RouteSchedule.js.map +2 -2
  52. package/components/RouteSchedule/RouteSchedule.md.scss +4 -2
  53. package/components/RouteSchedule/RouteSchedule.scss +12 -23
  54. package/components/RouteSchedule/index.js.map +2 -2
  55. package/components/ScaleLine/ScaleLine.js +11 -9
  56. package/components/ScaleLine/ScaleLine.js.map +2 -2
  57. package/components/ScaleLine/ScaleLine.scss +6 -4
  58. package/components/ScaleLine/index.js.map +2 -2
  59. package/components/StopsFinder/StopsFinder.js +141 -118
  60. package/components/StopsFinder/StopsFinder.js.map +2 -2
  61. package/components/StopsFinder/StopsFinderOption.js +11 -24
  62. package/components/StopsFinder/StopsFinderOption.js.map +2 -2
  63. package/components/StopsFinder/index.js.map +2 -2
  64. package/components/Zoom/Zoom.js +101 -62
  65. package/components/Zoom/Zoom.js.map +2 -2
  66. package/components/Zoom/Zoom.md.scss +3 -1
  67. package/components/Zoom/Zoom.scss +7 -5
  68. package/components/Zoom/index.js.map +2 -2
  69. package/images/geops_qr.png +0 -0
  70. package/package.json +81 -177
  71. package/propTypes.js +67 -0
  72. package/propTypes.js.map +7 -0
  73. package/setupTests.js +22 -0
  74. package/setupTests.js.map +7 -0
  75. package/themes/README.md +26 -0
  76. package/themes/default/components.scss +9 -13
  77. package/themes/default/examples.scss +20 -19
  78. package/themes/default/index.scss +3 -3
  79. package/themes/default/mixins.scss +7 -5
  80. package/themes/default/variables.scss +27 -25
  81. package/utils/GlobalsForOle.js +57 -57
  82. package/utils/GlobalsForOle.js.map +2 -2
  83. package/utils/KML.js +174 -49
  84. package/utils/KML.js.map +2 -2
  85. package/utils/Styles.js +7 -7
  86. package/utils/Styles.js.map +2 -2
  87. package/utils/getLayersAsFlatArray.js +14 -0
  88. package/utils/getLayersAsFlatArray.js.map +7 -0
  89. package/utils/getPolygonPattern.js.map +2 -2
  90. package/utils/timeUtils.js +11 -7
  91. package/utils/timeUtils.js.map +2 -2
  92. package/components/FilterButton/FilterButton.js +0 -66
  93. package/components/FilterButton/FilterButton.js.map +0 -7
  94. package/components/FilterButton/FilterButton.scss +0 -36
  95. package/components/FilterButton/index.js +0 -1
  96. package/components/FilterButton/index.js.map +0 -7
  97. package/components/FollowButton/FollowButton.js +0 -73
  98. package/components/FollowButton/FollowButton.js.map +0 -7
  99. package/components/FollowButton/FollowButton.scss +0 -36
  100. package/components/FollowButton/index.js +0 -1
  101. package/components/FollowButton/index.js.map +0 -7
  102. package/components/Search/Search.js +0 -166
  103. package/components/Search/Search.js.map +0 -7
  104. package/components/Search/Search.md.scss +0 -4
  105. package/components/Search/Search.scss +0 -78
  106. package/components/Search/SearchService.js +0 -48
  107. package/components/Search/SearchService.js.map +0 -7
  108. package/components/Search/engines/Engine.js +0 -19
  109. package/components/Search/engines/Engine.js.map +0 -7
  110. package/components/Search/engines/StopFinder.js +0 -30
  111. package/components/Search/engines/StopFinder.js.map +0 -7
  112. package/components/Search/index.js +0 -3
  113. package/components/Search/index.js.map +0 -7
  114. package/components/TrackerControl/TrackerControl.js +0 -116
  115. package/components/TrackerControl/TrackerControl.js.map +0 -7
  116. package/components/TrackerControl/TrackerControl.scss +0 -30
  117. package/components/TrackerControl/index.js +0 -1
  118. package/components/TrackerControl/index.js.map +0 -7
  119. package/images/FilterButton/filter.svg +0 -1
  120. package/images/FollowButton/follow.svg +0 -1
  121. package/images/baselayer/osm.baselayer.hot.png +0 -0
  122. package/images/baselayer/osm.baselayer.png +0 -0
  123. package/utils/KMLFormat.js +0 -69
  124. package/utils/KMLFormat.js.map +0 -7
@@ -1,77 +1,108 @@
1
- import React, { PureComponent } from "react";
2
- import PropTypes from "prop-types";
3
- import { defaults as defaultInteractions } from "ol/interaction";
1
+ import OLCollection from "ol/Collection";
4
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";
5
6
  import OLMap from "ol/Map";
6
- import OLCollection from "ol/Collection";
7
- import View from "ol/View";
8
7
  import { unByKey } from "ol/Observable";
9
- import Interaction from "ol/interaction/Interaction";
10
- import { Layer } from "mobility-toolbox-js/ol";
11
- import ResizeHandler from "../ResizeHandler";
8
+ import View from "ol/View";
9
+ import PropTypes from "prop-types";
10
+ import React, { PureComponent } from "react";
12
11
  const propTypes = {
12
+ /** Map animation options */
13
13
  animationOptions: PropTypes.shape({
14
14
  center: PropTypes.arrayOf(PropTypes.number),
15
15
  resolution: PropTypes.number,
16
16
  zoom: PropTypes.number
17
17
  }),
18
+ /** HTML aria-label. */
19
+ ariaLabel: PropTypes.string,
20
+ /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */
18
21
  center: PropTypes.arrayOf(PropTypes.number),
22
+ /** Class name of the map container */
19
23
  className: PropTypes.string,
24
+ /** Map extent */
20
25
  extent: PropTypes.arrayOf(PropTypes.number),
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
+ }),
35
+ /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */
21
36
  fitOptions: PropTypes.object,
37
+ /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */
22
38
  interactions: PropTypes.oneOfType([
23
39
  PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),
24
40
  PropTypes.instanceOf(OLCollection)
25
41
  ]),
42
+ /** Array of Openlayers layers */
26
43
  layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
44
+ /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */
27
45
  map: PropTypes.instanceOf(OLMap),
46
+ /**
47
+ * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.
48
+ * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
49
+ * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).
50
+ */
28
51
  onFeaturesClick: PropTypes.func,
29
- featuresClickOptions: PropTypes.shape({
30
- layerFilter: PropTypes.func,
31
- hitTolerance: PropTypes.number,
32
- checkWrapped: PropTypes.bool
33
- }),
52
+ /**
53
+ * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.
54
+ * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
55
+ * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).
56
+ */
34
57
  onFeaturesHover: PropTypes.func,
58
+ /**
59
+ * Callback when the map was moved.
60
+ * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).
61
+ */
35
62
  onMapMoved: PropTypes.func,
63
+ /** Map resolution */
36
64
  resolution: PropTypes.number,
37
- tabIndex: PropTypes.number,
65
+ /** The style of the map. */
38
66
  style: PropTypes.object,
39
- ariaLabel: PropTypes.string,
67
+ /** The tabIndex of the map. */
68
+ tabIndex: PropTypes.number,
69
+ /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */
40
70
  viewOptions: PropTypes.shape({
41
- minZoom: PropTypes.number,
42
- maxZoom: PropTypes.number,
43
71
  extent: PropTypes.array,
72
+ maxZoom: PropTypes.number,
73
+ minZoom: PropTypes.number,
44
74
  projection: PropTypes.string
45
75
  }),
76
+ /** Map zoom level */
46
77
  zoom: PropTypes.number
47
78
  };
48
79
  const defaultProps = {
49
80
  animationOptions: void 0,
81
+ ariaLabel: "map",
50
82
  center: [0, 0],
51
83
  className: "rs-map",
52
84
  extent: void 0,
85
+ featuresClickOptions: {
86
+ hitTolerance: 0
87
+ },
53
88
  fitOptions: {
54
89
  duration: 1e3,
55
- padding: [20, 20, 20, 20],
56
- maxZoom: 23
90
+ maxZoom: 23,
91
+ padding: [20, 20, 20, 20]
57
92
  },
58
- style: void 0,
59
93
  interactions: null,
60
94
  layers: [],
61
95
  map: null,
62
96
  onFeaturesClick: void 0,
63
- featuresClickOptions: {
64
- hitTolerance: 0
65
- },
66
97
  onFeaturesHover: void 0,
67
98
  onMapMoved: void 0,
68
99
  resolution: void 0,
100
+ style: void 0,
69
101
  tabIndex: void 0,
70
- ariaLabel: "map",
71
102
  viewOptions: {
72
- minZoom: 0,
73
- maxZoom: 22,
74
103
  extent: void 0,
104
+ maxZoom: 22,
105
+ minZoom: 0,
75
106
  projection: "EPSG:3857"
76
107
  },
77
108
  zoom: 1
@@ -79,7 +110,7 @@ const defaultProps = {
79
110
  class BasicMap extends PureComponent {
80
111
  constructor(props) {
81
112
  super(props);
82
- const { map, interactions } = this.props;
113
+ const { interactions, map } = this.props;
83
114
  this.map = map || new OLMap({
84
115
  controls: [],
85
116
  interactions: interactions || defaultInteractions({
@@ -90,17 +121,16 @@ class BasicMap extends PureComponent {
90
121
  this.state = {
91
122
  node: null
92
123
  };
93
- this.layers = [];
94
124
  this.moveEndRef = null;
95
125
  this.singleClickRef = null;
96
126
  this.pointerMoveRef = null;
97
127
  this.setNode = this.setNode.bind(this);
98
128
  }
99
129
  componentDidMount() {
100
- const { layers, extent, viewOptions, center, zoom, resolution } = this.props;
130
+ const { center, extent, layers, resolution, viewOptions, zoom } = this.props;
101
131
  const { node } = this.state;
102
132
  this.map.setTarget(node);
103
- this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));
133
+ this.map.setView(new View({ ...viewOptions, center, resolution, zoom }));
104
134
  const viewPort = this.map.getViewport();
105
135
  viewPort.style.touchAction = "none";
106
136
  viewPort.style.msTouchAction = "none";
@@ -120,15 +150,21 @@ class BasicMap extends PureComponent {
120
150
  extent,
121
151
  fitOptions,
122
152
  layers,
153
+ onFeaturesClick,
154
+ onFeaturesHover,
155
+ onMapMoved,
123
156
  resolution,
124
157
  viewOptions,
125
- zoom,
126
- onMapMoved,
127
- onFeaturesClick,
128
- onFeaturesHover
158
+ zoom
129
159
  } = this.props;
130
160
  const { node } = this.state;
131
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
+ }
132
168
  this.map.setTarget(node);
133
169
  if (!prevState.node && node && extent) {
134
170
  this.map.getView().fit(extent);
@@ -176,48 +212,15 @@ class BasicMap extends PureComponent {
176
212
  componentWillUnmount() {
177
213
  unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);
178
214
  }
179
- setNode(node) {
180
- this.setState({ node });
181
- }
182
- setLayers(layers = [], prevLayers = []) {
183
- for (let i = 0; i < prevLayers.length; i += 1) {
184
- this.terminateLayer(prevLayers[i]);
185
- }
186
- for (let i = 0; i < layers.length; i += 1) {
187
- this.initLayer(layers[i]);
188
- }
189
- this.layers = layers;
190
- }
191
215
  initLayer(layer) {
192
- if (layer.attachToMap) {
193
- layer.attachToMap(this.map);
194
- }
195
- if (layer.init) {
196
- layer.init(this.map);
216
+ if (!this.map?.getLayers()?.getArray()?.includes(layer)) {
217
+ this.map.addLayer(layer);
197
218
  }
198
- if (layer.olLayer && this.map.getLayers() && !this.map.getLayers().getArray().includes(layer.olLayer)) {
199
- this.map.addLayer(layer.olLayer);
200
- }
201
- const layers = layer.children || [];
219
+ const layers = layer.get("children") || layer.children || [];
202
220
  for (let i = 0; i < layers.length; i += 1) {
203
221
  this.initLayer(layers[i]);
204
222
  }
205
223
  }
206
- terminateLayer(layer) {
207
- const layers = layer.children || [];
208
- for (let i = 0; i < layers.length; i += 1) {
209
- this.terminateLayer(layers[i]);
210
- }
211
- if (layer.olLayer && this.map.getLayers() && this.map.getLayers().getArray().includes(layer.olLayer)) {
212
- this.map.removeLayer(layer.olLayer);
213
- }
214
- if (layer.terminate) {
215
- layer.terminate(this.map);
216
- }
217
- if (layer.detachFromMap) {
218
- layer.detachFromMap(this.map);
219
- }
220
- }
221
224
  listenMoveEnd() {
222
225
  const { onMapMoved } = this.props;
223
226
  unByKey(this.moveEndRef);
@@ -228,8 +231,19 @@ class BasicMap extends PureComponent {
228
231
  return onMapMoved(evt);
229
232
  });
230
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
+ }
231
245
  listenSingleClick() {
232
- const { onFeaturesClick, featuresClickOptions } = this.props;
246
+ const { featuresClickOptions, onFeaturesClick } = this.props;
233
247
  unByKey(this.singleClickRef);
234
248
  if (!onFeaturesClick) {
235
249
  return;
@@ -242,35 +256,39 @@ class BasicMap extends PureComponent {
242
256
  onFeaturesClick(features || [], evt);
243
257
  });
244
258
  }
245
- listenPointerMove() {
246
- const { onFeaturesHover } = this.props;
247
- unByKey(this.pointerMoveRef);
248
- if (!onFeaturesHover) {
249
- return;
250
- }
251
- this.pointerMoveRef = this.map.on("pointermove", (evt) => {
252
- const features = evt.map.getFeaturesAtPixel(evt.pixel);
253
- onFeaturesHover(features || [], evt);
254
- });
255
- }
256
259
  render() {
257
- const { className, tabIndex, ariaLabel, style } = this.props;
258
- const { node } = this.state;
259
- return /* @__PURE__ */ React.createElement("div", {
260
- className,
261
- ref: this.setNode,
262
- role: "presentation",
263
- "aria-label": ariaLabel,
264
- tabIndex,
265
- style
266
- }, /* @__PURE__ */ React.createElement(ResizeHandler, {
267
- maxHeightBrkpts: null,
268
- maxWidthBrkpts: null,
269
- observe: node,
270
- onResize: () => {
271
- this.map.updateSize();
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
272
270
  }
273
- }));
271
+ );
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
+ }
274
292
  }
275
293
  }
276
294
  BasicMap.propTypes = propTypes;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/BasicMap/BasicMap.js"],
4
- "sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport { defaults as defaultInteractions } from 'ol/interaction';\nimport { equals } from 'ol/extent';\nimport OLMap from 'ol/Map';\nimport OLCollection from 'ol/Collection';\nimport View from 'ol/View';\nimport { unByKey } from 'ol/Observable';\nimport Interaction from 'ol/interaction/Interaction';\nimport { Layer } from 'mobility-toolbox-js/ol';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /** Map animation options */\n animationOptions: PropTypes.shape({\n center: PropTypes.arrayOf(PropTypes.number),\n resolution: PropTypes.number,\n zoom: PropTypes.number,\n }),\n\n /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */\n center: PropTypes.arrayOf(PropTypes.number),\n\n /** Class name of the map container */\n className: PropTypes.string,\n\n /** Map extent */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */\n fitOptions: PropTypes.object,\n\n /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */\n interactions: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),\n PropTypes.instanceOf(OLCollection),\n ]),\n\n /** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).\n */\n onFeaturesClick: PropTypes.func,\n\n /**\n * Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.\n * https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel\n */\n featuresClickOptions: PropTypes.shape({\n layerFilter: PropTypes.func,\n hitTolerance: PropTypes.number,\n checkWrapped: PropTypes.bool,\n }),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).\n */\n onFeaturesHover: PropTypes.func,\n\n /**\n * Callback when the map was moved.\n * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).\n */\n onMapMoved: PropTypes.func,\n\n /** Map resolution */\n resolution: PropTypes.number,\n\n /** The tabIndex of the map. */\n tabIndex: PropTypes.number,\n\n /** The style of the map. */\n style: PropTypes.object,\n\n /** HTML aria-label. */\n ariaLabel: PropTypes.string,\n\n /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */\n viewOptions: PropTypes.shape({\n minZoom: PropTypes.number,\n maxZoom: PropTypes.number,\n extent: PropTypes.array,\n projection: PropTypes.string,\n }),\n\n /** Map zoom level */\n zoom: PropTypes.number,\n};\n\nconst defaultProps = {\n animationOptions: undefined,\n center: [0, 0],\n className: 'rs-map',\n extent: undefined,\n fitOptions: {\n duration: 1000,\n padding: [20, 20, 20, 20],\n maxZoom: 23,\n },\n style: undefined,\n interactions: null,\n layers: [],\n map: null,\n onFeaturesClick: undefined,\n featuresClickOptions: {\n hitTolerance: 0,\n },\n onFeaturesHover: undefined,\n onMapMoved: undefined,\n resolution: undefined,\n tabIndex: undefined,\n ariaLabel: 'map',\n viewOptions: {\n minZoom: 0,\n maxZoom: 22,\n extent: undefined,\n projection: 'EPSG:3857',\n },\n zoom: 1,\n};\n\n/**\n * The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n *\n * The map's view is created with the following parameters for the view:\n * - projection: 'EPSG:3857'\n * - zoom: 0\n * - minZoom: 0\n * - maxZoom: 22\n *\n * These options can be overridden using the viewOptions property.\n */\nclass BasicMap extends PureComponent {\n constructor(props) {\n super(props);\n const { map, interactions } = this.props;\n\n this.map =\n map ||\n new OLMap({\n controls: [],\n interactions:\n interactions ||\n defaultInteractions({\n altShiftDragRotate: false,\n pinchRotate: false,\n }),\n });\n\n this.state = {\n node: null,\n };\n\n this.layers = [];\n this.moveEndRef = null;\n this.singleClickRef = null;\n this.pointerMoveRef = null;\n this.setNode = this.setNode.bind(this);\n }\n\n componentDidMount() {\n const { layers, extent, viewOptions, center, zoom, resolution } =\n this.props;\n const { node } = this.state;\n this.map.setTarget(node);\n\n // We set the view here otherwise the map is not correctly zoomed.\n this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));\n\n // // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,\n // // so we have to force it to none for mobile.\n // // https://github.com/openlayers/openlayers/pull/10187/files\n const viewPort = this.map.getViewport();\n viewPort.style.touchAction = 'none';\n viewPort.style.msTouchAction = 'none';\n viewPort.setAttribute('touch-action', 'none');\n\n // Fit only work if the map has a size.\n if (this.map.getSize() && extent) {\n this.map.getView().fit(extent);\n }\n\n this.setLayers(layers);\n this.listenMoveEnd();\n this.listenSingleClick();\n this.listenPointerMove();\n }\n\n componentDidUpdate(prevProps, prevState) {\n const {\n animationOptions,\n center,\n extent,\n fitOptions,\n layers,\n resolution,\n viewOptions,\n zoom,\n onMapMoved,\n onFeaturesClick,\n onFeaturesHover,\n } = this.props;\n const { node } = this.state;\n\n if (prevState.node !== node) {\n this.map.setTarget(node);\n\n // When the node is set we reinitialize the extent with the extent property.\n if (!prevState.node && node && extent) {\n this.map.getView().fit(extent);\n }\n }\n\n if (prevProps.layers !== layers) {\n this.setLayers(layers, prevProps.layers);\n }\n\n // Creates a new view if necessary before updating the others prop.\n if (\n viewOptions &&\n JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)\n ) {\n // Re-create a view, ol doesn't provide any method to setExtent of view.\n this.map.setView(\n new View({\n ...viewOptions,\n center,\n resolution,\n zoom,\n }),\n );\n }\n\n const view = this.map.getView();\n\n if (animationOptions && prevProps.animationOptions !== animationOptions) {\n view.animate(animationOptions);\n }\n\n if (prevProps.center !== center) {\n view.setCenter(center);\n }\n\n if (zoom !== prevProps.zoom) {\n view.setZoom(zoom);\n }\n\n if (resolution !== prevProps.resolution) {\n view.setResolution(resolution);\n }\n\n if (extent && !equals(extent, prevProps.extent || [])) {\n view.fit(extent, fitOptions);\n }\n\n if (onMapMoved !== prevProps.onMapMoved) {\n this.listenMoveEnd();\n }\n\n if (onFeaturesClick !== prevProps.onFeaturesClick) {\n this.listenSingleClick();\n }\n\n if (onFeaturesHover !== prevProps.onFeaturesHover) {\n this.listenPointerMove();\n }\n }\n\n componentWillUnmount() {\n unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);\n }\n\n setNode(node) {\n this.setState({ node });\n }\n\n setLayers(layers = [], prevLayers = []) {\n for (let i = 0; i < prevLayers.length; i += 1) {\n this.terminateLayer(prevLayers[i]);\n }\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n this.layers = layers;\n }\n\n initLayer(layer) {\n if (layer.attachToMap) {\n layer.attachToMap(this.map);\n }\n\n if (layer.init) {\n layer.init(this.map);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n !this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.addLayer(layer.olLayer);\n }\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n terminateLayer(layer) {\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.terminateLayer(layers[i]);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.removeLayer(layer.olLayer);\n }\n\n if (layer.terminate) {\n layer.terminate(this.map);\n }\n\n if (layer.detachFromMap) {\n layer.detachFromMap(this.map);\n }\n }\n\n listenMoveEnd() {\n const { onMapMoved } = this.props;\n unByKey(this.moveEndRef);\n\n if (!onMapMoved) {\n return;\n }\n\n this.moveEndRef = this.map.on('moveend', (evt) => {\n return onMapMoved(evt);\n });\n }\n\n listenSingleClick() {\n const { onFeaturesClick, featuresClickOptions } = this.props;\n unByKey(this.singleClickRef);\n\n if (!onFeaturesClick) {\n return;\n }\n\n this.singleClickRef = this.map.on('singleclick', (evt) => {\n const features = evt.map.getFeaturesAtPixel(\n evt.pixel,\n featuresClickOptions,\n );\n onFeaturesClick(features || [], evt);\n });\n }\n\n listenPointerMove() {\n const { onFeaturesHover } = this.props;\n unByKey(this.pointerMoveRef);\n\n if (!onFeaturesHover) {\n return;\n }\n\n this.pointerMoveRef = this.map.on('pointermove', (evt) => {\n const features = evt.map.getFeaturesAtPixel(evt.pixel);\n onFeaturesHover(features || [], evt);\n });\n }\n\n render() {\n const { className, tabIndex, ariaLabel, style } = this.props;\n const { node } = this.state;\n return (\n <div\n className={className}\n ref={this.setNode}\n role=\"presentation\"\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n style={style}\n >\n <ResizeHandler\n maxHeightBrkpts={null}\n maxWidthBrkpts={null}\n observe={node}\n onResize={() => {\n this.map.updateSize();\n }}\n />\n </div>\n );\n }\n}\n\nBasicMap.propTypes = propTypes;\nB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M,EAAE,gBAAgB,IAAI,KAAK;AACjC,YAAQ,KAAK,cAAc;AAE3B,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AAEA,SAAK,iBAAiB,KAAK,IAAI,GAAG,eAAe,CAAC,QAAQ;AACxD,YAAM,WAAW,IAAI,IAAI,mBAAmB,IAAI,KAAK;AACrD,sBAAgB,YAAY,CAAC,GAAG,GAAG;AAAA,IACrC,CAAC;AAAA,EACH;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,WAAW,UAAU,WAAW,MAAM,IAAI,KAAK;AACvD,UAAM,EAAE,KAAK,IAAI,KAAK;AACtB,WACE,oCAAC;AAAA,MACC;AAAA,MACA,KAAK,KAAK;AAAA,MACV,MAAK;AAAA,MACL,cAAY;AAAA,MACZ;AAAA,MACA;AAAA,OAEA,oCAAC;AAAA,MACC,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,SAAS;AAAA,MACT,UAAU,MAAM;AACd,aAAK,IAAI,WAAW;AAAA,MACtB;AAAA,KACF,CACF;AAAA,EAEJ;AACF;AAEA,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,eAAe;",
4
+ "sourcesContent": ["import OLCollection from \"ol/Collection\";\nimport { equals } from \"ol/extent\";\nimport { defaults as defaultInteractions } from \"ol/interaction\";\nimport Interaction from \"ol/interaction/Interaction\";\nimport Layer from \"ol/layer/Layer\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport View from \"ol/View\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\n\nconst propTypes = {\n /** Map animation options */\n animationOptions: PropTypes.shape({\n center: PropTypes.arrayOf(PropTypes.number),\n resolution: PropTypes.number,\n zoom: PropTypes.number,\n }),\n\n /** HTML aria-label. */\n ariaLabel: PropTypes.string,\n\n /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */\n center: PropTypes.arrayOf(PropTypes.number),\n\n /** Class name of the map container */\n className: PropTypes.string,\n\n /** Map extent */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /**\n * Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.\n * https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel\n */\n featuresClickOptions: PropTypes.shape({\n checkWrapped: PropTypes.bool,\n hitTolerance: PropTypes.number,\n layerFilter: PropTypes.func,\n }),\n\n /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */\n fitOptions: PropTypes.object,\n\n /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */\n interactions: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),\n PropTypes.instanceOf(OLCollection),\n ]),\n\n /** Array of Openlayers layers */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).\n */\n onFeaturesClick: PropTypes.func,\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).\n */\n onFeaturesHover: PropTypes.func,\n\n /**\n * Callback when the map was moved.\n * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).\n */\n onMapMoved: PropTypes.func,\n\n /** Map resolution */\n resolution: PropTypes.number,\n\n /** The style of the map. */\n style: PropTypes.object,\n\n /** The tabIndex of the map. */\n tabIndex: PropTypes.number,\n\n /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */\n viewOptions: PropTypes.shape({\n extent: PropTypes.array,\n maxZoom: PropTypes.number,\n minZoom: PropTypes.number,\n projection: PropTypes.string,\n }),\n\n /** Map zoom level */\n zoom: PropTypes.number,\n};\n\nconst defaultProps = {\n animationOptions: undefined,\n ariaLabel: \"map\",\n center: [0, 0],\n className: \"rs-map\",\n extent: undefined,\n featuresClickOptions: {\n hitTolerance: 0,\n },\n fitOptions: {\n duration: 1000,\n maxZoom: 23,\n padding: [20, 20, 20, 20],\n },\n interactions: null,\n layers: [],\n map: null,\n onFeaturesClick: undefined,\n onFeaturesHover: undefined,\n onMapMoved: undefined,\n resolution: undefined,\n style: undefined,\n tabIndex: undefined,\n viewOptions: {\n extent: undefined,\n maxZoom: 22,\n minZoom: 0,\n projection: \"EPSG:3857\",\n },\n zoom: 1,\n};\n\n/**\n * The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n *\n * The map's view is created with the following parameters for the view:\n * - projection: 'EPSG:3857'\n * - zoom: 0\n * - minZoom: 0\n * - maxZoom: 22\n *\n * These options can be overridden using the viewOptions property.\n */\nclass BasicMap extends PureComponent {\n constructor(props) {\n super(props);\n const { interactions, map } = this.props;\n\n this.map =\n map ||\n new OLMap({\n controls: [],\n interactions:\n interactions ||\n defaultInteractions({\n altShiftDragRotate: false,\n pinchRotate: false,\n }),\n });\n\n this.state = {\n node: null,\n };\n\n this.moveEndRef = null;\n this.singleClickRef = null;\n this.pointerMoveRef = null;\n this.setNode = this.setNode.bind(this);\n }\n\n componentDidMount() {\n const { center, extent, layers, resolution, viewOptions, zoom } =\n this.props;\n const { node } = this.state;\n this.map.setTarget(node);\n\n // We set the view here otherwise the map is not correctly zoomed.\n this.map.setView(new View({ ...viewOptions, center, resolution, zoom }));\n\n // // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,\n // // so we have to force it to none for mobile.\n // // https://github.com/openlayers/openlayers/pull/10187/files\n const viewPort = this.map.getViewport();\n viewPort.style.touchAction = \"none\";\n viewPort.style.msTouchAction = \"none\";\n viewPort.setAttribute(\"touch-action\", \"none\");\n\n // Fit only work if the map has a size.\n if (this.map.getSize() && extent) {\n this.map.getView().fit(extent);\n }\n\n this.setLayers(layers);\n this.listenMoveEnd();\n this.listenSingleClick();\n this.listenPointerMove();\n }\n\n componentDidUpdate(prevProps, prevState) {\n const {\n animationOptions,\n center,\n extent,\n fitOptions,\n layers,\n onFeaturesClick,\n onFeaturesHover,\n onMapMoved,\n resolution,\n viewOptions,\n zoom,\n } = this.props;\n const { node } = this.state;\n\n if (prevState.node !== node) {\n if (zoom) {\n this.map.getView().setZoom(zoom);\n }\n\n if (resolution) {\n this.map.getView().setResolution(resolution);\n }\n this.map.setTarget(node);\n\n // When the node is set we reinitialize the extent with the extent property.\n if (!prevState.node && node && extent) {\n this.map.getView().fit(extent);\n }\n }\n\n if (prevProps.layers !== layers) {\n this.setLayers(layers, prevProps.layers);\n }\n\n // Creates a new view if necessary before updating the others prop.\n if (\n viewOptions &&\n JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)\n ) {\n // Re-create a view, ol doesn't provide any method to setExtent of view.\n this.map.setView(\n new View({\n ...viewOptions,\n center,\n resolution,\n zoom,\n }),\n );\n }\n\n const view = this.map.getView();\n\n if (animationOptions && prevProps.animationOptions !== animationOptions) {\n view.animate(animationOptions);\n }\n\n if (prevProps.center !== center) {\n view.setCenter(center);\n }\n\n if (zoom !== prevProps.zoom) {\n view.setZoom(zoom);\n }\n\n if (resolution !== prevProps.resolution) {\n view.setResolution(resolution);\n }\n\n if (extent && !equals(extent, prevProps.extent || [])) {\n view.fit(extent, fitOptions);\n }\n\n if (onMapMoved !== prevProps.onMapMoved) {\n this.listenMoveEnd();\n }\n\n if (onFeaturesClick !== prevProps.onFeaturesClick) {\n this.listenSingleClick();\n }\n\n if (onFeaturesHover !== prevProps.onFeaturesHover) {\n this.listenPointerMove();\n }\n }\n\n componentWillUnmount() {\n unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);\n }\n\n initLayer(layer) {\n if (!this.map?.getLayers()?.getArray()?.includes(layer)) {\n this.map.addLayer(layer);\n }\n\n const layers = layer.get(\"children\") || layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n listenMoveEnd() {\n const { onMapMoved } = this.props;\n unByKey(this.moveEndRef);\n\n if (!onMapMoved) {\n return;\n }\n\n this.moveEndRef = this.map.on(\"moveend\", (evt) => {\n return onMapMoved(evt);\n });\n }\n\n listenPointerMove() {\n const { onFeaturesHover } = this.props;\n unByKey(this.pointerMoveRef);\n\n if (!onFeaturesHover) {\n return;\n }\n\n this.pointerMoveRef = this.map.on(\"pointermove\", (evt) => {\n const features = evt.map.getFeaturesAtPixel(evt.pixel);\n onFeaturesHover(features || [], evt);\n });\n }\n\n listenSingleClick() {\n const { featuresClickOptions, onFeaturesClick } = this.props;\n unByKey(this.singleClickRef);\n\n if (!onFeaturesClick) {\n return;\n }\n\n this.singleClickRef = this.map.on(\"singleclick\", (evt) => {\n const features = evt.map.getFeaturesAtPixel(\n evt.pixel,\n featuresClickOptions,\n );\n onFeaturesClick(features || [], evt);\n });\n }\n\n render() {\n const { ariaLabel, className, style, tabIndex } = this.props;\n return (\n <div\n aria-label={ariaLabel}\n className={className}\n ref={this.setNode}\n role=\"presentation\"\n style={style}\n tabIndex={tabIndex}\n />\n );\n }\n\n setLayers(layers = [], prevLayers = []) {\n for (let i = 0; i < prevLayers.length; i += 1) {\n this.terminateLayer(prevLayers[i]);\n }\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n setNode(node) {\n this.setState({ node });\n }\n\n terminateLayer(layer) {\n const layers = layer.get(\"children\") || layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.terminateLayer(layers[i]);\n }\n\n if (this.map?.getLayers()?.getArray()?.includes(layer)) {\n this.map.removeLayer(layer);\n }\n }\n}\n\nBasicMap.propTypes = propTypes;\nBasicMap.defaultProps = defaultProps;\n\nexport default BasicMap;\n"],
5
+ "mappings": "AAAA,OAAO,kBAAkB;AACzB,SAAS,cAAc;AACvB,SAAS,YAAY,2BAA2B;AAChD,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AAErC,MAAM,YAAY;AAAA;AAAA,EAEhB,kBAAkB,UAAU,MAAM;AAAA,IAChC,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA,IAC1C,YAAY,UAAU;AAAA,IACtB,MAAM,UAAU;AAAA,EAClB,CAAC;AAAA;AAAA,EAGD,WAAW,UAAU;AAAA;AAAA,EAGrB,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA;AAAA,EAG1C,WAAW,UAAU;AAAA;AAAA,EAGrB,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,sBAAsB,UAAU,MAAM;AAAA,IACpC,cAAc,UAAU;AAAA,IACxB,cAAc,UAAU;AAAA,IACxB,aAAa,UAAU;AAAA,EACzB,CAAC;AAAA;AAAA,EAGD,YAAY,UAAU;AAAA;AAAA,EAGtB,cAAc,UAAU,UAAU;AAAA,IAChC,UAAU,QAAQ,UAAU,WAAW,WAAW,CAAC;AAAA,IACnD,UAAU,WAAW,YAAY;AAAA,EACnC,CAAC;AAAA;AAAA,EAGD,QAAQ,UAAU,QAAQ,UAAU,WAAW,K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C,cAAY;AAAA,QACZ;AAAA,QACA,KAAK,KAAK;AAAA,QACV,MAAK;AAAA,QACL;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EAEA,UAAU,SAAS,CAAC,GAAG,aAAa,CAAC,GAAG;AACtC,aAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK,GAAG;AAC7C,WAAK,eAAe,WAAW,CAAC,CAAC;AAAA,IACnC;AACA,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,WAAK,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,QAAQ,MAAM;AACZ,SAAK,SAAS,EAAE,KAAK,CAAC;AAAA,EACxB;AAAA,EAEA,eAAe,OAAO;AACpB,UAAM,SAAS,MAAM,IAAI,UAAU,KAAK,MAAM,YAAY,CAAC;AAC3D,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,WAAK,eAAe,OAAO,CAAC,CAAC;AAAA,IAC/B;AAEA,QAAI,KAAK,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,KAAK,GAAG;AACtD,WAAK,IAAI,YAAY,KAAK;AAAA,IAC5B;AAAA,EACF;AACF;AAEA,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/BasicMap/index.js"],
4
- "sourcesContent": ["export { default } from './BasicMap';\n"],
5
- "mappings": "AAAA,wBAAwB;",
4
+ "sourcesContent": ["export { default } from \"./BasicMap\";\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;",
6
6
  "names": []
7
7
  }