react-spatial 2.0.0-beta.1 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +5 -10
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +243 -220
  3. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
  4. package/components/BaseLayerSwitcher/BaseLayerSwitcher.scss +6 -5
  5. package/components/BaseLayerSwitcher/index.js +1 -3
  6. package/components/BaseLayerSwitcher/index.js.map +7 -1
  7. package/components/BasicMap/BasicMap.js +165 -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 +434 -556
  12. package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
  13. package/components/CanvasSaveButton/CanvasSaveButton.md.scss +1 -1
  14. package/components/CanvasSaveButton/index.js +1 -3
  15. package/components/CanvasSaveButton/index.js.map +7 -1
  16. package/components/Copyright/Copyright.js +44 -77
  17. package/components/Copyright/Copyright.js.map +7 -1
  18. package/components/Copyright/index.js +1 -3
  19. package/components/Copyright/index.js.map +7 -1
  20. package/components/FeatureExportButton/FeatureExportButton.js +44 -92
  21. package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
  22. package/components/FeatureExportButton/index.js +1 -3
  23. package/components/FeatureExportButton/index.js.map +7 -1
  24. package/components/FitExtent/FitExtent.js +31 -46
  25. package/components/FitExtent/FitExtent.js.map +7 -1
  26. package/components/FitExtent/index.js +1 -3
  27. package/components/FitExtent/index.js.map +7 -1
  28. package/components/Geolocation/Geolocation.js +158 -228
  29. package/components/Geolocation/Geolocation.js.map +7 -1
  30. package/components/Geolocation/Geolocation.scss +7 -5
  31. package/components/Geolocation/index.js +1 -3
  32. package/components/Geolocation/index.js.map +7 -1
  33. package/components/LayerTree/LayerTree.js +359 -357
  34. package/components/LayerTree/LayerTree.js.map +7 -1
  35. package/components/LayerTree/LayerTree.scss +4 -6
  36. package/components/LayerTree/index.js +1 -3
  37. package/components/LayerTree/index.js.map +7 -1
  38. package/components/MousePosition/MousePosition.js +71 -109
  39. package/components/MousePosition/MousePosition.js.map +7 -1
  40. package/components/MousePosition/index.js +1 -3
  41. package/components/MousePosition/index.js.map +7 -1
  42. package/components/NorthArrow/NorthArrow.js +37 -61
  43. package/components/NorthArrow/NorthArrow.js.map +7 -1
  44. package/components/NorthArrow/index.js +1 -3
  45. package/components/NorthArrow/index.js.map +7 -1
  46. package/components/Overlay/Overlay.js +93 -123
  47. package/components/Overlay/Overlay.js.map +7 -1
  48. package/components/Overlay/index.js +1 -3
  49. package/components/Overlay/index.js.map +7 -1
  50. package/components/Permalink/Permalink.js +194 -229
  51. package/components/Permalink/Permalink.js.map +7 -1
  52. package/components/Permalink/index.js +1 -3
  53. package/components/Permalink/index.js.map +7 -1
  54. package/components/Popup/Popup.js +139 -215
  55. package/components/Popup/Popup.js.map +7 -1
  56. package/components/Popup/Popup.md.scss +1 -0
  57. package/components/Popup/Popup.scss +3 -1
  58. package/components/Popup/index.js +1 -3
  59. package/components/Popup/index.js.map +7 -1
  60. package/components/ResizeHandler/ResizeHandler.js +88 -137
  61. package/components/ResizeHandler/ResizeHandler.js.map +7 -1
  62. package/components/ResizeHandler/index.js +1 -3
  63. package/components/ResizeHandler/index.js.map +7 -1
  64. package/components/RouteSchedule/RouteSchedule.js +227 -277
  65. package/components/RouteSchedule/RouteSchedule.js.map +7 -1
  66. package/components/RouteSchedule/RouteSchedule.md.scss +4 -2
  67. package/components/RouteSchedule/RouteSchedule.scss +12 -23
  68. package/components/RouteSchedule/index.js +1 -3
  69. package/components/RouteSchedule/index.js.map +7 -1
  70. package/components/ScaleLine/ScaleLine.js +17 -39
  71. package/components/ScaleLine/ScaleLine.js.map +7 -1
  72. package/components/ScaleLine/ScaleLine.scss +6 -4
  73. package/components/ScaleLine/index.js +1 -3
  74. package/components/ScaleLine/index.js.map +7 -1
  75. package/components/StopsFinder/StopsFinder.js +134 -162
  76. package/components/StopsFinder/StopsFinder.js.map +7 -1
  77. package/components/StopsFinder/StopsFinderOption.js +30 -60
  78. package/components/StopsFinder/StopsFinderOption.js.map +7 -1
  79. package/components/StopsFinder/index.js +1 -3
  80. package/components/StopsFinder/index.js.map +7 -1
  81. package/components/Zoom/Zoom.js +102 -106
  82. package/components/Zoom/Zoom.js.map +7 -1
  83. package/components/Zoom/Zoom.md.scss +3 -1
  84. package/components/Zoom/Zoom.scss +7 -5
  85. package/components/Zoom/index.js +1 -3
  86. package/components/Zoom/index.js.map +7 -1
  87. package/images/geops_qr.png +0 -0
  88. package/package.json +88 -182
  89. package/propTypes.js +36 -24
  90. package/propTypes.js.map +7 -1
  91. package/setupTests.js +21 -4
  92. package/setupTests.js.map +7 -1
  93. package/themes/README.md +26 -0
  94. package/themes/default/components.scss +9 -14
  95. package/themes/default/examples.scss +20 -20
  96. package/themes/default/index.scss +3 -3
  97. package/themes/default/mixins.scss +7 -5
  98. package/themes/default/variables.scss +27 -25
  99. package/utils/GlobalsForOle.js +72 -73
  100. package/utils/GlobalsForOle.js.map +7 -1
  101. package/utils/KML.js +320 -381
  102. package/utils/KML.js.map +7 -1
  103. package/utils/Styles.js +25 -33
  104. package/utils/Styles.js.map +7 -1
  105. package/utils/getLayersAsFlatArray.js +14 -0
  106. package/utils/getLayersAsFlatArray.js.map +7 -0
  107. package/utils/getPolygonPattern.js +11 -44
  108. package/utils/getPolygonPattern.js.map +7 -1
  109. package/utils/timeUtils.js +20 -35
  110. package/utils/timeUtils.js.map +7 -1
  111. package/LayerService.js +0 -193
  112. package/LayerService.js.map +0 -1
  113. package/LayerService.test.js +0 -160
  114. package/LayerService.test.js.map +0 -1
  115. package/Projections.js +0 -16
  116. package/Projections.js.map +0 -1
  117. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
  118. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
  119. package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
  120. package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
  121. package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
  122. package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
  123. package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
  124. package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
  125. package/components/BaseLayerToggler/index.js +0 -3
  126. package/components/BaseLayerToggler/index.js.map +0 -1
  127. package/components/BasicMap/BasicMap.test.js +0 -288
  128. package/components/BasicMap/BasicMap.test.js.map +0 -1
  129. package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
  130. package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
  131. package/components/Copyright/Copyright.test.js +0 -133
  132. package/components/Copyright/Copyright.test.js.map +0 -1
  133. package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
  134. package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
  135. package/components/FilterButton/FilterButton.js +0 -131
  136. package/components/FilterButton/FilterButton.js.map +0 -1
  137. package/components/FilterButton/FilterButton.scss +0 -36
  138. package/components/FilterButton/FilterButton.test.js +0 -48
  139. package/components/FilterButton/FilterButton.test.js.map +0 -1
  140. package/components/FilterButton/index.js +0 -3
  141. package/components/FilterButton/index.js.map +0 -1
  142. package/components/FitExtent/FitExtent.test.js +0 -44
  143. package/components/FitExtent/FitExtent.test.js.map +0 -1
  144. package/components/FollowButton/FollowButton.js +0 -143
  145. package/components/FollowButton/FollowButton.js.map +0 -1
  146. package/components/FollowButton/FollowButton.scss +0 -36
  147. package/components/FollowButton/FollowButton.test.js +0 -57
  148. package/components/FollowButton/FollowButton.test.js.map +0 -1
  149. package/components/FollowButton/index.js +0 -3
  150. package/components/FollowButton/index.js.map +0 -1
  151. package/components/Geolocation/Geolocation.test.js +0 -263
  152. package/components/Geolocation/Geolocation.test.js.map +0 -1
  153. package/components/LayerTree/LayerTree.test.js +0 -323
  154. package/components/LayerTree/LayerTree.test.js.map +0 -1
  155. package/components/MousePosition/MousePosition.test.js +0 -125
  156. package/components/MousePosition/MousePosition.test.js.map +0 -1
  157. package/components/NorthArrow/NorthArrow.test.js +0 -106
  158. package/components/NorthArrow/NorthArrow.test.js.map +0 -1
  159. package/components/Overlay/Overlay.test.js +0 -145
  160. package/components/Overlay/Overlay.test.js.map +0 -1
  161. package/components/Permalink/Permalink.test.js +0 -267
  162. package/components/Permalink/Permalink.test.js.map +0 -1
  163. package/components/Popup/Popup.test.js +0 -291
  164. package/components/Popup/Popup.test.js.map +0 -1
  165. package/components/ResizeHandler/ResizeHandler.test.js +0 -410
  166. package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
  167. package/components/RouteSchedule/RouteSchedule.test.js +0 -102
  168. package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
  169. package/components/ScaleLine/ScaleLine.test.js +0 -32
  170. package/components/ScaleLine/ScaleLine.test.js.map +0 -1
  171. package/components/Search/Search.js +0 -230
  172. package/components/Search/Search.js.map +0 -1
  173. package/components/Search/Search.md.scss +0 -4
  174. package/components/Search/Search.scss +0 -78
  175. package/components/Search/Search.test.js +0 -15
  176. package/components/Search/Search.test.js.map +0 -1
  177. package/components/Search/SearchService.js +0 -72
  178. package/components/Search/SearchService.js.map +0 -1
  179. package/components/Search/engines/Engine.js +0 -26
  180. package/components/Search/engines/Engine.js.map +0 -1
  181. package/components/Search/engines/StopFinder.js +0 -47
  182. package/components/Search/engines/StopFinder.js.map +0 -1
  183. package/components/Search/index.js +0 -6
  184. package/components/Search/index.js.map +0 -1
  185. package/components/StopsFinder/StopsFinder.test.js +0 -19
  186. package/components/StopsFinder/StopsFinder.test.js.map +0 -1
  187. package/components/TrackerControl/TrackerControl.js +0 -171
  188. package/components/TrackerControl/TrackerControl.js.map +0 -1
  189. package/components/TrackerControl/TrackerControl.scss +0 -30
  190. package/components/TrackerControl/TrackerControl.test.js +0 -17
  191. package/components/TrackerControl/TrackerControl.test.js.map +0 -1
  192. package/components/TrackerControl/index.js +0 -3
  193. package/components/TrackerControl/index.js.map +0 -1
  194. package/components/Zoom/Zoom.test.js +0 -150
  195. package/components/Zoom/Zoom.test.js.map +0 -1
  196. package/images/FilterButton/filter.svg +0 -1
  197. package/images/FollowButton/follow.svg +0 -1
  198. package/images/baselayer/osm.baselayer.hot.png +0 -0
  199. package/images/baselayer/osm.baselayer.png +0 -0
  200. package/styleguidist/ComponentsList.js +0 -52
  201. package/styleguidist/ComponentsList.js.map +0 -1
  202. package/styleguidist/StyleGuide.js +0 -253
  203. package/styleguidist/StyleGuide.js.map +0 -1
  204. package/utils/KML.test.js +0 -163
  205. package/utils/KML.test.js.map +0 -1
  206. package/utils/KMLFormat.js +0 -105
  207. package/utils/KMLFormat.js.map +0 -1
  208. package/utils/KMLFormat.test.js +0 -22
  209. package/utils/KMLFormat.test.js.map +0 -1
  210. package/utils/getPolygonPattern.test.js +0 -66
  211. package/utils/getPolygonPattern.test.js.map +0 -1
  212. package/utils/timeUtils.test.js +0 -32
  213. package/utils/timeUtils.test.js.map +0 -1
@@ -1,65 +1,50 @@
1
- function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; }
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import OLMap from 'ol/Map';
5
-
6
- var propTypes = {
1
+ import OLMap from "ol/Map";
2
+ import PropTypes from "prop-types";
3
+ import React from "react";
4
+ const propTypes = {
7
5
  /**
8
- * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
9
- */
10
- map: PropTypes.instanceOf(OLMap).isRequired,
11
-
12
- /**
13
- * The extent to be zoomed.
6
+ * Button content.
14
7
  */
15
- extent: PropTypes.arrayOf(PropTypes.number).isRequired,
16
-
8
+ children: PropTypes.node.isRequired,
17
9
  /**
18
10
  * CSS class for the fitExtent button.
19
11
  */
20
12
  className: PropTypes.string,
21
-
22
13
  /**
23
- * Button content.
14
+ * The extent to be zoomed.
24
15
  */
25
- children: PropTypes.node.isRequired,
26
- };
27
-
28
- var defaultProps = {
29
- className: 'rs-fit-extent',
16
+ extent: PropTypes.arrayOf(PropTypes.number).isRequired,
17
+ /**
18
+ * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
19
+ */
20
+ map: PropTypes.instanceOf(OLMap).isRequired
30
21
  };
31
-
32
- /**
33
- * The FitExtent component creates a button that updates the current extent of
34
- * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
35
- */
36
- function FitExtent(ref) {
37
- var map = ref.map;
38
- var extent = ref.extent;
39
- var className = ref.className;
40
- var children = ref.children;
41
- var rest = objectWithoutProperties( ref, ["map", "extent", "className", "children"] );
42
- var other = rest;
43
-
44
- var fit = function (evt) {
22
+ function FitExtent({
23
+ children,
24
+ className = "rs-fit-extent",
25
+ extent,
26
+ map,
27
+ ...other
28
+ }) {
29
+ const fit = (evt) => {
45
30
  if (evt.which && evt.which !== 13) {
46
31
  return;
47
32
  }
48
33
  map.getView().cancelAnimations();
49
34
  map.getView().fit(extent, map.getSize());
50
35
  };
51
-
52
- return (
53
- React.createElement( 'div', Object.assign({},
54
- { className: className, role: "button", tabIndex: "0", onClick: fit, onKeyPress: fit }, other),
55
- children
56
- )
36
+ return /* @__PURE__ */ React.createElement(
37
+ "div",
38
+ {
39
+ className,
40
+ onClick: fit,
41
+ onKeyPress: fit,
42
+ role: "button",
43
+ tabIndex: "0",
44
+ ...other
45
+ },
46
+ children
57
47
  );
58
48
  }
59
-
60
49
  FitExtent.propTypes = propTypes;
61
- FitExtent.defaultProps = defaultProps;
62
-
63
50
  export default FitExtent;
64
-
65
- //# sourceMappingURL=FitExtent.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"FitExtent.js","sources":["../../../src/components/FitExtent/FitExtent.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\n\nconst propTypes = {\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 * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n};\n\nconst defaultProps = {\n className: 'rs-fit-extent',\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({ map, extent, className, children, ...other }) {\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 role=\"button\"\n tabIndex=\"0\"\n onClick={fit}\n onKeyPress={fit}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\nFitExtent.defaultProps = defaultProps;\n\nexport default FitExtent;\n"],"names":["const"],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B;AACAA,GAAK,CAAC,SAAS,GAAG;AAClB;AACA;AACA;AACA,EAAE,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,UAAU;AAC7C;AACA;AACA;AACA;AACA,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,UAAU;AACxD;AACA;AACA;AACA;AACA,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM;AAC7B;AACA;AACA;AACA;AACA,EAAE,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;AACrC,CAAC,CAAC;AACF;AACAA,GAAK,CAAC,YAAY,GAAG;AACrB,EAAE,SAAS,EAAE,eAAe;AAC5B,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA,SAAS,SAAS,IAA+C,EAAE,CAA9C;oBAAK;0BAAQ;gCAAW;8BAAU;wFAAG;;AAAU;AACpE,EAAEA,GAAK,CAAC,GAAG,YAAG,CAAC,GAAG,EAAK;AACvB,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,KAAK,EAAE,EAAE;AACvC,MAAM,OAAO;AACb,KAAK;AACL,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC;AACrC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC7C,GAAG,CAAC;AACJ;AACA,EAAE,OAAO;AACT,IAAI,sBAAC,uBAAG;AACR,QAAM,WAAW,SAAU,EACrB,MAAK,QAAQ,EACb,UAAS,GAAG,EACZ,SAAS,GAAI,EACb,YAAY,KAAI,EAEZ,OACL;AACL,MAAO,QAAS;AAChB,IAAI,CAAM;AACV,GAAG,CAAC;AACJ,CAAC;AACD;AACA,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC;AAChC,SAAS,CAAC,YAAY,GAAG,YAAY,CAAC;AACtC;AACA,eAAe,SAAS,CAAC;"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/FitExtent/FitExtent.js"],
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
+ "names": []
7
+ }
@@ -1,3 +1 @@
1
- export { default } from './FitExtent';
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export { default } from "./FitExtent";
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/FitExtent/index.js"],"sourcesContent":["export { default } from './FitExtent';\n"],"names":[],"mappings":"AAAA,SAAS,OAAO,QAAQ,aAAa,CAAC;"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/FitExtent/index.js"],
4
+ "sourcesContent": ["export { default } from \"./FitExtent\";\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;",
6
+ "names": []
7
+ }
@@ -1,233 +1,150 @@
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 = {
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";
5
+ import { unByKey } from "ol/Observable";
6
+ import { transform } from "ol/proj";
7
+ import VectorSource from "ol/source/Vector";
8
+ import Circle from "ol/style/Circle";
9
+ import Fill from "ol/style/Fill";
10
+ import Stroke from "ol/style/Stroke";
11
+ import Style from "ol/style/Style";
12
+ import PropTypes from "prop-types";
13
+ import React, { PureComponent } from "react";
14
+ import { FaRegDotCircle } from "react-icons/fa";
15
+ const propTypes = {
21
16
  /**
22
- * CSS class of the button.
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.
23
19
  */
24
- className: PropTypes.string,
25
-
20
+ alwaysRecenterToPosition: PropTypes.bool,
26
21
  /**
27
22
  * Children content of the Geolocation button.
28
23
  */
29
24
  children: PropTypes.node,
30
-
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
+ ]),
31
37
  /**
32
38
  * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
33
39
  */
34
40
  map: PropTypes.instanceOf(OLMap).isRequired,
35
-
36
41
  /**
37
- * Function triggered when geolocating is not successful.
42
+ * If true, the map will never center to the current position
38
43
  */
39
- onError: PropTypes.func,
40
-
44
+ neverCenterToPosition: PropTypes.bool,
41
45
  /**
42
- * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.
46
+ * If true, the map is not centered after it has been dragged once.
43
47
  */
44
- onSuccess: PropTypes.func,
45
-
48
+ noCenterAfterDrag: PropTypes.bool,
46
49
  /**
47
50
  * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.
48
51
  */
49
52
  onActivate: PropTypes.func,
50
-
51
53
  /**
52
54
  * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..
53
55
  */
54
56
  onDeactivate: PropTypes.func,
55
-
56
- /**
57
- * If true, the map is not centered after it has been dragged once.
58
- */
59
- noCenterAfterDrag: PropTypes.bool,
60
-
61
57
  /**
62
- * If true, the map will constantly recenter to the current Position
58
+ * Function triggered when geolocating is not successful.
63
59
  */
64
- alwaysRecenterToPosition: PropTypes.bool,
65
-
60
+ onError: PropTypes.func,
66
61
  /**
67
- * Color (Number array with rgb values) or style function.
68
- * 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.
69
63
  */
70
- colorOrStyleFunc: PropTypes.oneOfType([
71
- PropTypes.arrayOf(PropTypes.number),
72
- PropTypes.func ]),
64
+ onSuccess: PropTypes.func
73
65
  };
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 () {},
82
- noCenterAfterDrag: false,
66
+ const defaultProps = {
83
67
  alwaysRecenterToPosition: true,
68
+ children: /* @__PURE__ */ React.createElement(FaRegDotCircle, { focusable: false }),
69
+ className: "rs-geolocation",
84
70
  colorOrStyleFunc: [235, 0, 0],
71
+ neverCenterToPosition: false,
72
+ noCenterAfterDrag: false,
73
+ onActivate: () => {
74
+ },
75
+ onDeactivate: () => {
76
+ },
77
+ onError: () => {
78
+ },
79
+ onSuccess: () => {
80
+ }
85
81
  };
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
-
82
+ class Geolocation extends PureComponent {
83
+ constructor(props) {
84
+ super(props);
95
85
  this.layer = new VectorLayer({
96
- source: new VectorSource(),
86
+ source: new VectorSource()
97
87
  });
98
-
99
88
  this.isRecenteringToPosition = true;
100
-
101
89
  this.state = {
102
- active: false,
90
+ active: false
103
91
  };
104
- this.point = undefined;
92
+ this.point = void 0;
105
93
  }
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 () {
112
- 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
-
122
- if (!geolocation) {
123
- onError();
124
- } else if (!active) {
125
- this.activate();
126
- } else {
127
- this.deactivate();
128
- }
129
- };
130
-
131
- Geolocation.prototype.error = function error () {
132
- var ref = this.props;
133
- var onError = ref.onError;
134
-
135
- this.deactivate();
136
- onError();
137
- };
138
-
139
- Geolocation.prototype.deactivate = function deactivate () {
140
- var ref = this.props;
141
- var map = ref.map;
142
- var onDeactivate = ref.onDeactivate;
143
- window.clearInterval(this.interval);
144
- this.layer.setMap(null);
145
- navigator.geolocation.clearWatch(this.watch);
146
-
147
- this.setState({
148
- active: false,
149
- });
150
-
151
- this.isRecenteringToPosition = true;
152
- this.point = undefined;
153
- onDeactivate(map, this);
154
- 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
-
94
+ activate() {
95
+ const { map, noCenterAfterDrag, onActivate } = this.props;
165
96
  this.projection = map.getView().getProjection().getCode();
166
97
  this.point = new Point([0, 0]);
167
98
  this.highlight();
168
99
  this.layer.setMap(map);
169
100
  this.setState({ active: true });
170
-
171
101
  this.watch = navigator.geolocation.watchPosition(
172
102
  this.update.bind(this),
173
103
  this.error.bind(this),
174
104
  {
175
- enableHighAccuracy: true,
105
+ enableHighAccuracy: true
176
106
  }
177
107
  );
178
-
179
108
  if (noCenterAfterDrag) {
180
- this.dragListener = map.on('pointerdrag', function () {
181
- this$1.isRecenteringToPosition = false;
109
+ this.dragListener = map.on("pointerdrag", () => {
110
+ this.isRecenteringToPosition = false;
182
111
  });
183
112
  }
184
-
185
113
  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(
199
- [longitude, latitude],
200
- 'EPSG:4326',
201
- this.projection
202
- );
203
- this.point.setCoordinates(position);
204
-
205
- if (this.isRecenteringToPosition) {
206
- map.getView().setCenter(position);
207
- if (!alwaysRecenterToPosition) {
208
- this.isRecenteringToPosition = false;
209
- }
210
- }
211
-
212
- 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,
114
+ }
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);
135
+ }
136
+ highlight() {
137
+ const { colorOrStyleFunc } = this.props;
138
+ const feature = new Feature({
139
+ geometry: this.point
220
140
  });
221
-
222
141
  if (Array.isArray(colorOrStyleFunc)) {
223
- var color = colorOrStyleFunc;
224
-
225
- var decrease = true;
226
- var opacity = 0.5;
227
- var rotation = 0;
228
-
142
+ const color = colorOrStyleFunc;
143
+ let decrease = true;
144
+ let opacity = 0.5;
145
+ let rotation = 0;
229
146
  window.clearInterval(this.interval);
230
- this.interval = window.setInterval(function () {
147
+ this.interval = window.setInterval(() => {
231
148
  rotation += 0.03;
232
149
  decrease = opacity < 0.1 ? false : decrease;
233
150
  decrease = opacity > 0.5 ? true : decrease;
@@ -236,79 +153,92 @@ var Geolocation = /*@__PURE__*/(function (PureComponent) {
236
153
  feature.changed();
237
154
  }
238
155
  }, 50);
239
-
240
- feature.setStyle(function () {
241
- var circleStyle = new Style({
156
+ feature.setStyle(() => {
157
+ const circleStyle = new Style({
242
158
  image: new Circle({
243
- radius: 20,
244
- rotation: rotation,
245
159
  fill: new Fill({
246
- color: 'rgba(255, 255, 255, 0.01)',
160
+ color: "rgba(255, 255, 255, 0.01)"
247
161
  }),
162
+ radius: 20,
163
+ rotation,
248
164
  stroke: new Stroke({
165
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,
249
166
  lineDash: [30, 10],
250
- width: 6,
251
- color: ("rgba(" + (color[0]) + ", " + (color[1]) + ", " + (color[2]) + ", " + opacity + ")"),
252
- }),
253
- }),
167
+ width: 6
168
+ })
169
+ })
254
170
  });
255
-
256
171
  circleStyle.getImage().setRotation(rotation);
257
-
258
172
  return [
259
173
  new Style({
260
174
  image: new Circle({
261
- radius: 10,
262
175
  fill: new Fill({
263
- color: ("rgba(" + (color[0]) + ", " + (color[1]) + ", " + (color[2]) + ", 0.5)"),
176
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`
264
177
  }),
265
- }),
178
+ radius: 10
179
+ })
266
180
  }),
267
- circleStyle ];
181
+ circleStyle
182
+ ];
268
183
  });
269
184
  } else {
270
185
  feature.setStyle(colorOrStyleFunc);
271
186
  }
272
-
273
187
  this.layer.getSource().clear();
274
188
  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 ));
189
+ }
190
+ render() {
191
+ const { children, className } = this.props;
192
+ const other = Object.entries(this.props).reduce((props, [key, value]) => {
193
+ return propTypes[key] ? props : { ...props, [key]: value };
290
194
  }, {});
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
- )
195
+ const { active } = this.state;
196
+ return /* @__PURE__ */ React.createElement(
197
+ "div",
198
+ {
199
+ className: `${className} ${active ? "rs-active" : ""}`,
200
+ onClick: () => {
201
+ return this.toggle();
202
+ },
203
+ onKeyPress: (e) => {
204
+ return e.which === 13 && this.toggle();
205
+ },
206
+ role: "button",
207
+ tabIndex: "0",
208
+ ...other
209
+ },
210
+ children
303
211
  );
304
- };
305
-
306
- return Geolocation;
307
- }(PureComponent));
308
-
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
+ }
309
242
  Geolocation.propTypes = propTypes;
310
243
  Geolocation.defaultProps = defaultProps;
311
-
312
244
  export default Geolocation;
313
-
314
- //# sourceMappingURL=Geolocation.js.map