react-spatial 1.5.3 → 1.5.4

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 (294) hide show
  1. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +231 -0
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
  3. package/components/BaseLayerSwitcher/index.js +1 -0
  4. package/components/BaseLayerSwitcher/index.js.map +7 -0
  5. package/components/BasicMap/BasicMap.js +278 -0
  6. package/components/BasicMap/BasicMap.js.map +7 -0
  7. package/components/BasicMap/index.js +1 -0
  8. package/components/BasicMap/index.js.map +7 -0
  9. package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +93 -320
  10. package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
  11. package/components/CanvasSaveButton/index.js +1 -0
  12. package/components/CanvasSaveButton/index.js.map +7 -0
  13. package/components/Copyright/Copyright.js +55 -0
  14. package/components/Copyright/Copyright.js.map +7 -0
  15. package/components/Copyright/index.js +1 -0
  16. package/components/Copyright/index.js.map +7 -0
  17. package/components/FeatureExportButton/FeatureExportButton.js +62 -0
  18. package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
  19. package/components/FeatureExportButton/index.js +1 -0
  20. package/components/FeatureExportButton/index.js.map +7 -0
  21. package/components/FitExtent/FitExtent.js +32 -0
  22. package/components/FitExtent/FitExtent.js.map +7 -0
  23. package/components/FitExtent/index.js +1 -0
  24. package/components/FitExtent/index.js.map +7 -0
  25. package/{src/components → components}/Geolocation/Geolocation.js +61 -144
  26. package/components/Geolocation/Geolocation.js.map +7 -0
  27. package/components/Geolocation/index.js +1 -0
  28. package/components/Geolocation/index.js.map +7 -0
  29. package/components/LayerTree/LayerTree.js +278 -0
  30. package/components/LayerTree/LayerTree.js.map +7 -0
  31. package/components/LayerTree/index.js +1 -0
  32. package/components/LayerTree/index.js.map +7 -0
  33. package/components/MousePosition/MousePosition.js +110 -0
  34. package/components/MousePosition/MousePosition.js.map +7 -0
  35. package/components/MousePosition/index.js +1 -0
  36. package/components/MousePosition/index.js.map +7 -0
  37. package/components/NorthArrow/NorthArrow.js +43 -0
  38. package/components/NorthArrow/NorthArrow.js.map +7 -0
  39. package/components/NorthArrow/index.js +1 -0
  40. package/components/NorthArrow/index.js.map +7 -0
  41. package/components/Overlay/Overlay.js +122 -0
  42. package/components/Overlay/Overlay.js.map +7 -0
  43. package/components/Overlay/index.js +1 -0
  44. package/components/Overlay/index.js.map +7 -0
  45. package/components/Permalink/Permalink.js +206 -0
  46. package/components/Permalink/Permalink.js.map +7 -0
  47. package/components/Permalink/index.js +1 -0
  48. package/components/Permalink/index.js.map +7 -0
  49. package/{src/components → components}/Popup/Popup.js +55 -165
  50. package/components/Popup/Popup.js.map +7 -0
  51. package/components/Popup/index.js +1 -0
  52. package/components/Popup/index.js.map +7 -0
  53. package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -50
  54. package/components/ResizeHandler/ResizeHandler.js.map +7 -0
  55. package/components/ResizeHandler/index.js +1 -0
  56. package/components/ResizeHandler/index.js.map +7 -0
  57. package/components/RouteSchedule/RouteSchedule.js +223 -0
  58. package/components/RouteSchedule/RouteSchedule.js.map +7 -0
  59. package/components/RouteSchedule/index.js +1 -0
  60. package/components/RouteSchedule/index.js.map +7 -0
  61. package/components/ScaleLine/ScaleLine.js +32 -0
  62. package/components/ScaleLine/ScaleLine.js.map +7 -0
  63. package/components/ScaleLine/index.js +1 -0
  64. package/components/ScaleLine/index.js.map +7 -0
  65. package/components/StopsFinder/StopsFinder.js +210 -0
  66. package/components/StopsFinder/StopsFinder.js.map +7 -0
  67. package/components/StopsFinder/StopsFinderOption.js +51 -0
  68. package/components/StopsFinder/StopsFinderOption.js.map +7 -0
  69. package/components/StopsFinder/index.js +1 -0
  70. package/components/StopsFinder/index.js.map +7 -0
  71. package/components/Zoom/Zoom.js +130 -0
  72. package/components/Zoom/Zoom.js.map +7 -0
  73. package/components/Zoom/index.js +1 -0
  74. package/components/Zoom/index.js.map +7 -0
  75. package/package.json +1 -1
  76. package/{src/propTypes.js → propTypes.js} +12 -16
  77. package/propTypes.js.map +7 -0
  78. package/{src/setupTests.js → setupTests.js} +1 -1
  79. package/setupTests.js.map +7 -0
  80. package/utils/GlobalsForOle.js +94 -0
  81. package/utils/GlobalsForOle.js.map +7 -0
  82. package/utils/KML.js +412 -0
  83. package/utils/KML.js.map +7 -0
  84. package/utils/KMLFormat.js +69 -0
  85. package/utils/KMLFormat.js.map +7 -0
  86. package/{src/utils → utils}/Styles.js +14 -20
  87. package/utils/Styles.js.map +7 -0
  88. package/{src/utils → utils}/getPolygonPattern.js +6 -34
  89. package/utils/getPolygonPattern.js.map +7 -0
  90. package/{src/utils → utils}/timeUtils.js +5 -22
  91. package/utils/timeUtils.js.map +7 -0
  92. package/.github/workflows/conventional-pr-title.yml +0 -21
  93. package/.github/workflows/main.yml +0 -28
  94. package/.husky/commit-msg +0 -4
  95. package/.husky/post-checkout +0 -4
  96. package/.husky/post-merge +0 -4
  97. package/.husky/post-rebase +0 -4
  98. package/.husky/pre-commit +0 -4
  99. package/.nvmrc +0 -1
  100. package/.whitesource +0 -8
  101. package/CHANGELOG.md +0 -65
  102. package/DEVELOP.md +0 -113
  103. package/__mocks__/mapbox-gl.js +0 -11
  104. package/__mocks__/resize-observer-polyfill.js +0 -9
  105. package/babel.config.js +0 -3
  106. package/commitlint.config.js +0 -1
  107. package/data/topic1.js +0 -119
  108. package/data/topic2.js +0 -28
  109. package/doc/README.md +0 -21
  110. package/doc/doc-config.json +0 -4
  111. package/pull_request_template.md +0 -16
  112. package/renovate.json +0 -4
  113. package/scripts/read-pkg-json.js +0 -17
  114. package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
  115. package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
  116. package/src/components/BaseLayerSwitcher/README.md +0 -61
  117. package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
  118. package/src/components/BaseLayerSwitcher/index.js +0 -1
  119. package/src/components/BasicMap/BasicMap.js +0 -413
  120. package/src/components/BasicMap/BasicMap.test.js +0 -281
  121. package/src/components/BasicMap/README.md +0 -18
  122. package/src/components/BasicMap/index.js +0 -1
  123. package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
  124. package/src/components/CanvasSaveButton/README.md +0 -76
  125. package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
  126. package/src/components/CanvasSaveButton/index.js +0 -1
  127. package/src/components/Copyright/Copyright.js +0 -89
  128. package/src/components/Copyright/Copyright.test.js +0 -134
  129. package/src/components/Copyright/README.md +0 -36
  130. package/src/components/Copyright/index.js +0 -1
  131. package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
  132. package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
  133. package/src/components/FeatureExportButton/README.md +0 -76
  134. package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
  135. package/src/components/FeatureExportButton/index.js +0 -1
  136. package/src/components/FitExtent/FitExtent.js +0 -62
  137. package/src/components/FitExtent/FitExtent.test.js +0 -48
  138. package/src/components/FitExtent/README.md +0 -34
  139. package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
  140. package/src/components/FitExtent/index.js +0 -1
  141. package/src/components/Geolocation/Geolocation.test.js +0 -267
  142. package/src/components/Geolocation/README.md +0 -25
  143. package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
  144. package/src/components/Geolocation/index.js +0 -1
  145. package/src/components/LayerTree/LayerTree.js +0 -487
  146. package/src/components/LayerTree/LayerTree.test.js +0 -337
  147. package/src/components/LayerTree/README.md +0 -92
  148. package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
  149. package/src/components/LayerTree/index.js +0 -1
  150. package/src/components/MousePosition/MousePosition.js +0 -175
  151. package/src/components/MousePosition/MousePosition.test.js +0 -132
  152. package/src/components/MousePosition/README.md +0 -50
  153. package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
  154. package/src/components/MousePosition/index.js +0 -1
  155. package/src/components/NorthArrow/NorthArrow.js +0 -75
  156. package/src/components/NorthArrow/NorthArrow.test.js +0 -104
  157. package/src/components/NorthArrow/README.md +0 -59
  158. package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
  159. package/src/components/NorthArrow/index.js +0 -1
  160. package/src/components/Overlay/Overlay.js +0 -176
  161. package/src/components/Overlay/Overlay.test.js +0 -149
  162. package/src/components/Overlay/README.md +0 -59
  163. package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
  164. package/src/components/Overlay/index.js +0 -1
  165. package/src/components/Permalink/Permalink.js +0 -326
  166. package/src/components/Permalink/Permalink.test.js +0 -285
  167. package/src/components/Permalink/README.md +0 -105
  168. package/src/components/Permalink/index.js +0 -1
  169. package/src/components/Popup/Popup.test.js +0 -307
  170. package/src/components/Popup/README.md +0 -93
  171. package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
  172. package/src/components/Popup/index.js +0 -1
  173. package/src/components/README.md +0 -41
  174. package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
  175. package/src/components/ResizeHandler/index.js +0 -1
  176. package/src/components/RouteSchedule/README.md +0 -118
  177. package/src/components/RouteSchedule/RouteSchedule.js +0 -370
  178. package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
  179. package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
  180. package/src/components/RouteSchedule/index.js +0 -1
  181. package/src/components/ScaleLine/README.md +0 -29
  182. package/src/components/ScaleLine/ScaleLine.js +0 -50
  183. package/src/components/ScaleLine/ScaleLine.test.js +0 -30
  184. package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
  185. package/src/components/ScaleLine/index.js +0 -1
  186. package/src/components/StopsFinder/README.md +0 -50
  187. package/src/components/StopsFinder/StopsFinder.js +0 -284
  188. package/src/components/StopsFinder/StopsFinder.test.js +0 -17
  189. package/src/components/StopsFinder/StopsFinderOption.js +0 -61
  190. package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
  191. package/src/components/StopsFinder/index.js +0 -1
  192. package/src/components/Zoom/README.md +0 -25
  193. package/src/components/Zoom/Zoom.js +0 -180
  194. package/src/components/Zoom/Zoom.test.js +0 -141
  195. package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
  196. package/src/components/Zoom/index.js +0 -1
  197. package/src/styleguidist/ComponentsList.js +0 -52
  198. package/src/styleguidist/StyleGuide.js +0 -277
  199. package/src/styleguidist/styleguidist.css +0 -38
  200. package/src/utils/GlobalsForOle.js +0 -99
  201. package/src/utils/KML.js +0 -594
  202. package/src/utils/KML.test.js +0 -337
  203. package/src/utils/KMLFormat.js +0 -100
  204. package/src/utils/KMLFormat.test.js +0 -50
  205. package/src/utils/__snapshots__/KML.test.js.snap.KML-readFeatures()-and-writeFeatures()-should-read-and-write-lineDash-and-fillPattern-style-for-polygon.canvas-image.png +0 -0
  206. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
  207. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-3-(diagonal-line-from-bottom-left-tot-top-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
  208. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-4-(diagonal-line-from-top-left-to-bottom-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
  209. package/src/utils/getPolygonPattern.test.js +0 -61
  210. package/src/utils/timeUtils.test.js +0 -30
  211. package/styleguide.config.js +0 -251
  212. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
  213. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
  214. /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
  215. /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
  216. /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
  217. /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
  218. /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
  219. /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
  220. /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
  221. /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
  222. /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
  223. /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
  224. /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
  225. /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
  226. /package/{src/components → components}/Overlay/Overlay.scss +0 -0
  227. /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
  228. /package/{src/components → components}/Popup/Popup.md.scss +0 -0
  229. /package/{src/components → components}/Popup/Popup.scss +0 -0
  230. /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
  231. /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
  232. /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
  233. /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
  234. /package/{src/components → components}/Zoom/Zoom.scss +0 -0
  235. /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
  236. /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
  237. /package/{src/images → images}/RouteSchedule/line.png +0 -0
  238. /package/{src/images → images}/RouteSchedule/station.png +0 -0
  239. /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
  240. /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
  241. /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
  242. /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
  243. /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
  244. /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
  245. /package/{src/images → images}/favicon.png +0 -0
  246. /package/{src/images → images}/geops_logo.png +0 -0
  247. /package/{src/images → images}/geops_logo.svg +0 -0
  248. /package/{src/images → images}/geops_qr.png +0 -0
  249. /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
  250. /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
  251. /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
  252. /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
  253. /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
  254. /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
  255. /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
  256. /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
  257. /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
  258. /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
  259. /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
  260. /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
  261. /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
  262. /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
  263. /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
  264. /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
  265. /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
  266. /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
  267. /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
  268. /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
  269. /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
  270. /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
  271. /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
  272. /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
  273. /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
  274. /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
  275. /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
  276. /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
  277. /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
  278. /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
  279. /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
  280. /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
  281. /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
  282. /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
  283. /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
  284. /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
  285. /package/{src/images → images}/northArrow.svg +0 -0
  286. /package/{src/images → images}/northArrow.url.svg +0 -0
  287. /package/{src/images → images}/northArrowCircle.svg +0 -0
  288. /package/{src/images → images}/northArrowCircle.url.svg +0 -0
  289. /package/{src/themes → themes}/README.md +0 -0
  290. /package/{src/themes → themes}/default/components.scss +0 -0
  291. /package/{src/themes → themes}/default/examples.scss +0 -0
  292. /package/{src/themes → themes}/default/index.scss +0 -0
  293. /package/{src/themes → themes}/default/mixins.scss +0 -0
  294. /package/{src/themes → themes}/default/variables.scss +0 -0
@@ -1,34 +0,0 @@
1
-
2
- The following example demonstrates the use of FitExtent.
3
-
4
- ```jsx
5
- import React from 'react';
6
- import { MapboxLayer } from 'mobility-toolbox-js/ol';
7
- import Tile from 'ol/layer/Tile';
8
- import OSM from 'ol/source/OSM';
9
- import Map from 'ol/Map';
10
- import { geopsTheme, Header, Footer } from '@geops/geops-ui';
11
- import { ThemeProvider } from '@material-ui/core/styles';
12
- import Button from '@material-ui/core/Button';
13
- import FitExtent from 'react-spatial/components/FitExtent';
14
- import BasicMap from 'react-spatial/components/BasicMap';
15
-
16
- const extent = [-15380353.1391, 2230738.2886, -6496535.908, 6927029.2369];
17
-
18
- const map = new Map({ controls: [] });
19
-
20
- const layers = [
21
- new MapboxLayer({
22
- url: `https://maps.geops.io/styles/travic_v2/style.json?key=${apiKey}`,
23
- }),
24
- ];
25
-
26
- <ThemeProvider theme={geopsTheme}>
27
- <BasicMap map={map} layers={layers} tabIndex={0} />
28
- <FitExtent map={map} extent={extent}>
29
- <Button>
30
- Fit to US
31
- </Button>
32
- </FitExtent>
33
- </ThemeProvider>
34
- ```
@@ -1,13 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Button should match snapshot. 1`] = `
4
- <div
5
- className="rs-fit-extent"
6
- onClick={[Function]}
7
- onKeyPress={[Function]}
8
- role="button"
9
- tabIndex="0"
10
- >
11
- FitExtent
12
- </div>
13
- `;
@@ -1 +0,0 @@
1
- export { default } from './FitExtent';
@@ -1,267 +0,0 @@
1
- import React from 'react';
2
- import renderer from 'react-test-renderer';
3
- import { configure, mount, shallow } from 'enzyme';
4
- import Adapter from '@cfaester/enzyme-adapter-react-18';
5
-
6
- import 'jest-canvas-mock';
7
- import Map from 'ol/Map';
8
- import View from 'ol/View';
9
- import MapEvent from 'ol/MapEvent';
10
- import Geolocation from './Geolocation';
11
-
12
- configure({ adapter: new Adapter() });
13
-
14
- const geolocationBackup = global.navigator.geolocation;
15
-
16
- const mockGeolocation = () => {
17
- const mock = {
18
- clearWatch: jest.fn(),
19
- getCurrentPosition: jest.fn(),
20
- watchPosition: (onSuccess) => {
21
- onSuccess({
22
- coords: {
23
- latitude: 47.9913611,
24
- longitude: 7.84868,
25
- accuracy: 55,
26
- },
27
- timestamp: 1552660077044,
28
- });
29
- },
30
- };
31
-
32
- global.navigator.geolocation = mock;
33
- };
34
-
35
- const mockMissingGeolocation = () => {
36
- delete global.navigator.geolocation;
37
- };
38
-
39
- const restoreGeolocation = () => {
40
- global.navigator.geolocation = geolocationBackup;
41
- };
42
-
43
- class CallbackHandler {
44
- static onError() {}
45
-
46
- static onSuccess() {}
47
-
48
- static onActivate() {}
49
-
50
- static onDeactivate() {}
51
- }
52
-
53
- describe('Geolocation', () => {
54
- let map;
55
-
56
- beforeEach(() => {
57
- const target = document.createElement('div');
58
- const { style } = target;
59
- style.position = 'absolute';
60
- style.left = '-1000px';
61
- style.top = '-1000px';
62
- style.width = '100px';
63
- style.height = '100px';
64
- document.body.appendChild(target);
65
-
66
- map = new Map({
67
- target,
68
- view: new View({
69
- center: [0, 0],
70
- resolutions: [1],
71
- zoom: 0,
72
- }),
73
- });
74
- map.renderSync();
75
- });
76
-
77
- afterEach(() => {
78
- const target = map.getTarget();
79
- map.setTarget(null);
80
- if (target && target.parentNode) {
81
- target.parentNode.removeChild(target);
82
- }
83
- map.dispose();
84
- });
85
-
86
- describe('should match snapshot', () => {
87
- test('minimum props', () => {
88
- const component = renderer.create(<Geolocation map={map} />);
89
- const tree = component.toJSON();
90
- expect(tree).toMatchSnapshot();
91
- });
92
-
93
- test('with title', () => {
94
- const component = renderer.create(
95
- <Geolocation map={map} title="Lokalisieren" />,
96
- );
97
- const tree = component.toJSON();
98
- expect(tree).toMatchSnapshot();
99
- });
100
-
101
- test('with class name', () => {
102
- const component = renderer.create(
103
- <Geolocation map={map} className="my-class-name" />,
104
- );
105
- const tree = component.toJSON();
106
- expect(tree).toMatchSnapshot();
107
- });
108
- });
109
-
110
- test('should use children', () => {
111
- mockGeolocation();
112
-
113
- const wrapper = mount(<Geolocation map={map}>test</Geolocation>);
114
-
115
- const text = wrapper.find('.rs-geolocation').first().text();
116
-
117
- expect(text).toBe('test');
118
-
119
- restoreGeolocation();
120
- });
121
-
122
- describe('button classes', () => {
123
- test('class should be active', () => {
124
- mockGeolocation();
125
-
126
- const wrapper = mount(<Geolocation map={map} />);
127
- const basic = wrapper.getDOMNode();
128
-
129
- wrapper.find('.rs-geolocation').first().simulate('click');
130
-
131
- expect(basic.className).toBe('rs-geolocation rs-active');
132
-
133
- restoreGeolocation();
134
- });
135
-
136
- test('class should not be active', () => {
137
- mockGeolocation();
138
-
139
- const wrapper = mount(<Geolocation map={map} />);
140
- const basic = wrapper.getDOMNode();
141
-
142
- wrapper
143
- .find('.rs-geolocation')
144
- .first()
145
- .simulate('click')
146
- .simulate('click');
147
-
148
- expect(basic.className).toBe('rs-geolocation ');
149
-
150
- restoreGeolocation();
151
- });
152
- });
153
-
154
- test(`highlight on first toggle`, () => {
155
- mockGeolocation();
156
-
157
- const component = shallow(<Geolocation map={map} />);
158
- const instance = component.instance();
159
- const spy = jest.spyOn(instance, 'highlight');
160
- instance.toggle();
161
- expect(spy).toHaveBeenCalled();
162
-
163
- restoreGeolocation();
164
- });
165
-
166
- test(`success/activate/deactivate callback functions should be called`, () => {
167
- mockGeolocation();
168
- const spyOnSuccess = jest.spyOn(CallbackHandler, 'onSuccess');
169
- const spyOnActivate = jest.spyOn(CallbackHandler, 'onActivate');
170
- const spyOnDeactivate = jest.spyOn(CallbackHandler, 'onDeactivate');
171
-
172
- const wrapper = mount(
173
- <Geolocation
174
- map={map}
175
- onSuccess={() => {
176
- return CallbackHandler.onSuccess();
177
- }}
178
- onActivate={() => {
179
- return CallbackHandler.onActivate();
180
- }}
181
- onDeactivate={() => {
182
- return CallbackHandler.onDeactivate();
183
- }}
184
- />,
185
- );
186
-
187
- wrapper.find('.rs-geolocation').first().simulate('click');
188
-
189
- expect(spyOnActivate).toHaveBeenCalled();
190
- expect(spyOnSuccess).toHaveBeenCalled();
191
-
192
- wrapper.find('.rs-geolocation').first().simulate('click');
193
-
194
- expect(spyOnDeactivate).toHaveBeenCalled();
195
-
196
- restoreGeolocation();
197
- });
198
-
199
- test(`error function should be called`, () => {
200
- mockMissingGeolocation();
201
-
202
- const spy = jest.spyOn(CallbackHandler, 'onError');
203
-
204
- const wrapper = mount(
205
- <Geolocation
206
- map={map}
207
- onError={() => {
208
- return CallbackHandler.onError();
209
- }}
210
- />,
211
- );
212
-
213
- wrapper.find('.rs-geolocation').first().simulate('click');
214
-
215
- expect(spy).toHaveBeenCalled();
216
-
217
- restoreGeolocation();
218
- });
219
-
220
- describe('map centering', () => {
221
- test('centers map', () => {
222
- mockGeolocation();
223
-
224
- const center1 = [742952.8821531708, 6330118.608483334];
225
- map.getView().setCenter(center1);
226
-
227
- const component = shallow(<Geolocation map={map} />);
228
- component.instance().toggle();
229
-
230
- const center2 = map.getView().getCenter();
231
- expect(center1).not.toEqual(center2);
232
-
233
- restoreGeolocation();
234
- });
235
-
236
- test('sets isRecenteringToPosition=false after pointerdrag event with the noCenterAfterDrag prop', () => {
237
- mockGeolocation();
238
-
239
- const component = shallow(<Geolocation map={map} noCenterAfterDrag />);
240
- component.instance().toggle();
241
-
242
- expect(component.instance().isRecenteringToPosition).toEqual(true);
243
-
244
- map.dispatchEvent(new MapEvent('pointerdrag', map));
245
- expect(component.instance().isRecenteringToPosition).toEqual(false);
246
-
247
- restoreGeolocation();
248
- });
249
- });
250
-
251
- test('custom style function', () => {
252
- mockGeolocation();
253
-
254
- const styleFunc = jest.fn();
255
-
256
- const component = shallow(
257
- <Geolocation map={map} colorOrStyleFunc={styleFunc} />,
258
- );
259
- const instance = component.instance();
260
- instance.toggle();
261
- const style = instance.layer.getSource().getFeatures()[0].getStyle();
262
-
263
- expect(style).toBe(styleFunc);
264
-
265
- restoreGeolocation();
266
- });
267
- });
@@ -1,25 +0,0 @@
1
-
2
- The following example demonstrates the use of Geolocation.
3
-
4
- ```jsx
5
- import React from 'react';
6
- import { MapboxLayer } from 'mobility-toolbox-js/ol';
7
- import Tile from 'ol/layer/Tile';
8
- import OSM from 'ol/source/OSM';
9
- import Map from 'ol/Map';
10
- import Geolocation from 'react-spatial/components/Geolocation';
11
- import BasicMap from 'react-spatial/components/BasicMap';
12
-
13
- const map = new Map({ controls: [] });
14
-
15
- const layers = [
16
- new MapboxLayer({
17
- url: `https://maps.geops.io/styles/travic_v2/style.json?key=${apiKey}`,
18
- }),
19
- ];
20
-
21
- <div className="rs-geolocation-example">
22
- <BasicMap map={map} layers={layers} tabIndex={0} />
23
- <Geolocation map={map} />
24
- </div>
25
- ```
@@ -1,92 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Geolocation should match snapshot minimum props 1`] = `
4
- <div
5
- className="rs-geolocation "
6
- onClick={[Function]}
7
- onKeyPress={[Function]}
8
- role="button"
9
- tabIndex="0"
10
- >
11
- <svg
12
- fill="currentColor"
13
- focusable={false}
14
- height="1em"
15
- stroke="currentColor"
16
- strokeWidth="0"
17
- style={
18
- {
19
- "color": undefined,
20
- }
21
- }
22
- viewBox="0 0 512 512"
23
- width="1em"
24
- xmlns="http://www.w3.org/2000/svg"
25
- >
26
- <path
27
- d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
28
- />
29
- </svg>
30
- </div>
31
- `;
32
-
33
- exports[`Geolocation should match snapshot with class name 1`] = `
34
- <div
35
- className="my-class-name "
36
- onClick={[Function]}
37
- onKeyPress={[Function]}
38
- role="button"
39
- tabIndex="0"
40
- >
41
- <svg
42
- fill="currentColor"
43
- focusable={false}
44
- height="1em"
45
- stroke="currentColor"
46
- strokeWidth="0"
47
- style={
48
- {
49
- "color": undefined,
50
- }
51
- }
52
- viewBox="0 0 512 512"
53
- width="1em"
54
- xmlns="http://www.w3.org/2000/svg"
55
- >
56
- <path
57
- d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
58
- />
59
- </svg>
60
- </div>
61
- `;
62
-
63
- exports[`Geolocation should match snapshot with title 1`] = `
64
- <div
65
- className="rs-geolocation "
66
- onClick={[Function]}
67
- onKeyPress={[Function]}
68
- role="button"
69
- tabIndex="0"
70
- title="Lokalisieren"
71
- >
72
- <svg
73
- fill="currentColor"
74
- focusable={false}
75
- height="1em"
76
- stroke="currentColor"
77
- strokeWidth="0"
78
- style={
79
- {
80
- "color": undefined,
81
- }
82
- }
83
- viewBox="0 0 512 512"
84
- width="1em"
85
- xmlns="http://www.w3.org/2000/svg"
86
- >
87
- <path
88
- d="M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"
89
- />
90
- </svg>
91
- </div>
92
- `;
@@ -1 +0,0 @@
1
- export { default } from './Geolocation';