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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/LayerTree/LayerTree.js"],
4
+ "sourcesContent": ["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, getLayersAsFlatArray } from 'mobility-toolbox-js/ol';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: 'rs-layer-tree',\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: 'Show layer',\n layerHide: 'Hide layer',\n subLayerShow: 'Show sublayer',\n subLayerHide: 'Hide sublayer',\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return l.children.filter((c) => {\n return !isItemHidden(c) && c.get('isAlwaysExpanded');\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayers() {\n const { layers, expandChildren } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer();\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on('propertychange', () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === 'function'\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\n .filter((c) => {\n return !isItemHidden(c) && !c.get('isAlwaysExpanded');\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer, inputProps) {\n const { titles, isItemHidden } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get('group') ? 'radio' : 'checkbox';\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get('isAlwaysExpanded')\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? 'collapsed' : 'expanded'\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get('isAlwaysExpanded'),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? 'rs-visible' : ''}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,4BAA4B;AAC5C,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA,EAIhB,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA,EAKrD,WAAW,UAAU;AAAA,EAKrB,SAAS,UAAU;AAAA,EASnB,cAAc,UAAU;AAAA,EAKxB,oBAAoB,UAAU;AAAA,EAS9B,YAAY,UAAU;AAAA,EAYtB,mBAAmB,UAAU;AAAA,EAS7B,kB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KAAK,QAAQ;AAAA,IAC3D;AAEA,WACE,oCAAC;AAAA,MAAI,WAAW,mBAAmB;AAAA,MAAG,KAAK,MAAM;AAAA,OAC/C,oCAAC;AAAA,MACC,WAAW,sBAAsB,MAAM,UAAU,eAAe;AAAA,MAChE,OAAO;AAAA,QACL,aAAa,GAAG,UAAU;AAAA,MAC5B;AAAA,OAEC,oBACG,kBAAkB,OAAO,IAAI,IAC7B,KAAK,kBAAkB,KAAK,CAClC,GACC,oBAAoB,iBAAiB,OAAO,OAAO,IAAI,GACvD,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU;AACtC,aAAO,KAAK,WAAW,OAAO,QAAQ,CAAC;AAAA,IACzC,CAAC,GACA,mBAAmB,gBAAgB,OAAO,OAAO,IAAI,CACxD;AAAA,EAEJ;AAAA,EAEA,aAAa;AACX,UAAM,EAAE,aAAa,IAAI,KAAK;AAC9B,UAAM,EAAE,UAAU,IAAI,KAAK;AAE3B,QAAI,CAAC,WAAW,UAAU,QAAQ;AAChC,aAAO;AAAA,IACT;AAEA,WACE,0DACG,UAAU,SACR,OAAO,CAAC,MAAM;AACb,aAAO,CAAC,aAAa,CAAC;AAAA,IACxB,CAAC,EACA,QAAQ,EACR,IAAI,CAAC,MAAM;AACV,aAAO,KAAK,WAAW,GAAG,CAAC;AAAA,IAC7B,CAAC,CACL;AAAA,EAEJ;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,oCAAC;AAAA,MAAI;AAAA,OAAuB,KAAK,WAAW,CAAE;AAAA,EACvD;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./LayerTree";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/LayerTree/index.js"],
4
+ "sourcesContent": ["export { default } from './LayerTree';\n"],
5
+ "mappings": "AAAA,wBAAwB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,110 @@
1
+ import React, { useState, useRef, useEffect, useCallback } from "react";
2
+ import PropTypes from "prop-types";
3
+ import OLMap from "ol/Map";
4
+ import { createStringXY } from "ol/coordinate";
5
+ import OLMousePosition from "ol/control/MousePosition";
6
+ const propTypes = {
7
+ map: PropTypes.instanceOf(OLMap).isRequired,
8
+ projections: PropTypes.arrayOf(
9
+ PropTypes.shape({
10
+ label: PropTypes.string.isRequired,
11
+ value: PropTypes.string.isRequired,
12
+ format: PropTypes.func
13
+ })
14
+ ),
15
+ projectionValue: PropTypes.shape({
16
+ label: PropTypes.string.isRequired,
17
+ value: PropTypes.string.isRequired,
18
+ format: PropTypes.func
19
+ }),
20
+ onChange: PropTypes.func
21
+ };
22
+ const defaultProps = {
23
+ onChange: () => {
24
+ },
25
+ projections: [
26
+ {
27
+ label: "EPSG:4326",
28
+ value: "EPSG:4326"
29
+ },
30
+ {
31
+ label: "EPSG:3857",
32
+ value: "EPSG:3857"
33
+ }
34
+ ],
35
+ projectionValue: null
36
+ };
37
+ function MousePosition({
38
+ map,
39
+ projections,
40
+ projectionValue,
41
+ onChange,
42
+ ...other
43
+ }) {
44
+ const [projection, setProjection] = useState(
45
+ projections && (projectionValue && projections.find((p) => {
46
+ return p.value === projectionValue.value;
47
+ }) || projections[0])
48
+ );
49
+ const [control, setControl] = useState();
50
+ const ref = useRef();
51
+ useEffect(() => {
52
+ const mousePosition = new OLMousePosition({
53
+ target: ref.current,
54
+ undefinedHTML: "&nbsp;",
55
+ className: ""
56
+ });
57
+ map.addControl(mousePosition);
58
+ setControl(mousePosition);
59
+ return () => {
60
+ map.removeControl(mousePosition);
61
+ };
62
+ }, [map]);
63
+ useEffect(() => {
64
+ if (!projection || !control) {
65
+ return;
66
+ }
67
+ control.setProjection(projection.value);
68
+ control.setCoordinateFormat(projection.format || createStringXY(4));
69
+ }, [projection, control]);
70
+ useEffect(() => {
71
+ if (projections) {
72
+ const proj = projectionValue && projections.find((p) => {
73
+ return p.value === projectionValue.value;
74
+ }) || projections[0];
75
+ setProjection(proj);
76
+ }
77
+ }, [projections, projectionValue]);
78
+ const onChangeCb = useCallback(
79
+ (evt) => {
80
+ const newProj = projections.find((opt) => {
81
+ return evt.target.value === opt.value;
82
+ });
83
+ setProjection(newProj);
84
+ onChange(evt, newProj);
85
+ },
86
+ [onChange, projections]
87
+ );
88
+ if (!projection || !projections || !projections.length) {
89
+ return null;
90
+ }
91
+ return /* @__PURE__ */ React.createElement("div", {
92
+ className: "rs-mouse-position",
93
+ ...other
94
+ }, /* @__PURE__ */ React.createElement("select", {
95
+ className: "rs-select",
96
+ value: projection.value,
97
+ onChange: onChangeCb
98
+ }, projections.map((option) => {
99
+ return /* @__PURE__ */ React.createElement("option", {
100
+ key: option.value,
101
+ value: option.value
102
+ }, option.label);
103
+ })), /* @__PURE__ */ React.createElement("span", {
104
+ ref,
105
+ className: "rs-coordinates"
106
+ }));
107
+ }
108
+ MousePosition.propTypes = propTypes;
109
+ MousePosition.defaultProps = defaultProps;
110
+ export default React.memo(MousePosition);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/MousePosition/MousePosition.js"],
4
+ "sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { createStringXY } from 'ol/coordinate';\nimport OLMousePosition from 'ol/control/MousePosition';\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 * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: 'EPSG:4326',\n value: 'EPSG:4326',\n },\n {\n label: 'EPSG:3857',\n value: 'EPSG:3857',\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n undefinedHTML: '&nbsp;',\n className: '',\n });\n map.addControl(mousePosition);\n setControl(mousePosition);\n\n return () => {\n map.removeControl(mousePosition);\n };\n }, [map]);\n\n useEffect(() => {\n if (!projection || !control) {\n return;\n }\n control.setProjection(projection.value);\n control.setCoordinateFormat(projection.format || createStringXY(4));\n }, [projection, control]);\n\n useEffect(() => {\n if (projections) {\n const proj =\n (projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0];\n setProjection(proj);\n }\n }, [projections, projectionValue]);\n\n const onChangeCb = useCallback(\n (evt) => {\n const newProj = projections.find((opt) => {\n return evt.target.value === opt.value;\n });\n setProjection(newProj);\n onChange(evt, newProj);\n },\n [onChange, projections],\n );\n\n if (!projection || !projections || !projections.length) {\n return null;\n }\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-mouse-position\" {...other}>\n <select\n className=\"rs-select\"\n value={projection.value}\n onChange={onChangeCb}\n >\n {projections.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </select>\n <span ref={ref} className=\"rs-coordinates\" />\n </div>\n );\n}\n\nMousePosition.propTypes = propTypes;\nMousePosition.defaultProps = defaultProps;\n\nexport default React.memo(MousePosition);\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,UAAU,QAAQ,WAAW,mBAAmB;AAChE,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAC/B,OAAO,qBAAqB;AAE5B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,aAAa,UAAU;AAAA,IACrB,UAAU,MAAM;AAAA,MAId,OAAO,UAAU,OAAO;AAAA,MAMxB,OAAO,UAAU,OAAO;AAAA,MAKxB,QAAQ,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAKA,iBAAiB,UAAU,MAAM;AAAA,IAI/B,OAAO,UAAU,OAAO;AAAA,IAMxB,OAAO,UAAU,OAAO;AAAA,IAKxB,QAAQ,UAAU;AAAA,EACpB,CAAC;AAAA,EAOD,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,aAAa;AAAA,IACX;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,iBAAiB;AACnB;AAMA,SAAS,cAAc;AAAA,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QAAQ;AACtD,WAAO;AAAA,EACT;AAEA,SAEE,oCAAC;AAAA,IAAI,WAAU;AAAA,IAAqB,GAAG;AAAA,KACrC,oCAAC;AAAA,IACC,WAAU;AAAA,IACV,OAAO,WAAW;AAAA,IAClB,UAAU;AAAA,KAET,YAAY,IAAI,CAAC,WAAW;AAC3B,WACE,oCAAC;AAAA,MAAO,KAAK,OAAO;AAAA,MAAO,OAAO,OAAO;AAAA,OACtC,OAAO,KACV;AAAA,EAEJ,CAAC,CACH,GACA,oCAAC;AAAA,IAAK;AAAA,IAAU,WAAU;AAAA,GAAiB,CAC7C;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./MousePosition";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/MousePosition/index.js"],
4
+ "sourcesContent": ["export { default } from './MousePosition';\n"],
5
+ "mappings": "AAAA,wBAAwB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,43 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import OLMap from "ol/Map";
4
+ import { unByKey } from "ol/Observable";
5
+ import { toDegrees } from "ol/math";
6
+ import NorthArrowSimple from "../../images/northArrow.svg";
7
+ import NorthArrowCircle from "../../images/northArrowCircle.svg";
8
+ const propTypes = {
9
+ map: PropTypes.instanceOf(OLMap).isRequired,
10
+ rotationOffset: PropTypes.number,
11
+ circled: PropTypes.bool,
12
+ children: PropTypes.node
13
+ };
14
+ const defaultProps = {
15
+ rotationOffset: 0,
16
+ circled: false,
17
+ children: null
18
+ };
19
+ const getRotation = (map, rotationOffset) => {
20
+ return toDegrees(map.getView().getRotation()) + rotationOffset;
21
+ };
22
+ function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
23
+ const [rotation, setRotation] = useState(rotationOffset);
24
+ useEffect(() => {
25
+ if (!map) {
26
+ return null;
27
+ }
28
+ const key = map.on("postrender", () => {
29
+ setRotation(getRotation(map, rotationOffset));
30
+ });
31
+ return () => {
32
+ unByKey(key);
33
+ };
34
+ }, [map, rotationOffset]);
35
+ return /* @__PURE__ */ React.createElement("div", {
36
+ className: "rs-north-arrow",
37
+ ...other,
38
+ style: { transform: `rotate(${rotation}deg)` }
39
+ }, children || (circled ? /* @__PURE__ */ React.createElement(NorthArrowCircle, null) : /* @__PURE__ */ React.createElement(NorthArrowSimple, null)));
40
+ }
41
+ NorthArrow.propTypes = propTypes;
42
+ NorthArrow.defaultProps = defaultProps;
43
+ export default React.memo(NorthArrow);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
4
+ "sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport { toDegrees } from 'ol/math';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\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 * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return toDegrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,gBAAgB,UAAU;AAAA,EAK1B,SAAS,UAAU;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,UAAU,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAClD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,aAAa,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE,oCAAC;AAAA,IACC,WAAU;AAAA,IAET,GAAG;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,eAAe;AAAA,KAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./NorthArrow";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/NorthArrow/index.js"],
4
+ "sourcesContent": ["export { default } from './NorthArrow';\n"],
5
+ "mappings": "AAAA,wBAAwB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,122 @@
1
+ import React, { Component, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { Resizable } from "re-resizable";
4
+ import ResizeHandler from "../ResizeHandler";
5
+ const propTypes = {
6
+ className: PropTypes.string,
7
+ children: PropTypes.node,
8
+ observe: PropTypes.oneOfType([
9
+ PropTypes.string,
10
+ PropTypes.node,
11
+ PropTypes.instanceOf(Component),
12
+ PropTypes.shape({ current: PropTypes.node }),
13
+ PropTypes.shape({ current: PropTypes.instanceOf(Component) })
14
+ ]),
15
+ isMobileResizable: PropTypes.bool,
16
+ mobileSize: PropTypes.shape({
17
+ minimalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
18
+ maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
19
+ defaultSize: PropTypes.shape({
20
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
21
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
22
+ }),
23
+ size: PropTypes.shape({
24
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
25
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
26
+ })
27
+ }),
28
+ thresholdWidthForMobile: PropTypes.number,
29
+ onResizeStop: PropTypes.func,
30
+ onResizeStart: PropTypes.func
31
+ };
32
+ const defaultMobileSize = {
33
+ defaultSize: {
34
+ width: "100%",
35
+ height: "25%"
36
+ },
37
+ size: void 0,
38
+ maximalHeight: "100%",
39
+ minimalHeight: "25%"
40
+ };
41
+ const defaultProps = {
42
+ className: null,
43
+ children: null,
44
+ observe: null,
45
+ isMobileResizable: true,
46
+ mobileSize: defaultMobileSize,
47
+ thresholdWidthForMobile: 768,
48
+ onResizeStop: () => {
49
+ },
50
+ onResizeStart: () => {
51
+ }
52
+ };
53
+ const Overlay = ({
54
+ observe,
55
+ className,
56
+ children,
57
+ isMobileResizable,
58
+ mobileSize,
59
+ onResizeStop,
60
+ onResizeStart,
61
+ thresholdWidthForMobile
62
+ }) => {
63
+ const [isMobile, setIsMobile] = useState();
64
+ const onResize = (entries) => {
65
+ for (let i = 0; i < entries.length; i += 1) {
66
+ const { width } = entries[i].contentRect;
67
+ setIsMobile(width <= thresholdWidthForMobile);
68
+ }
69
+ };
70
+ let resizableMobileSize;
71
+ if (mobileSize) {
72
+ resizableMobileSize = { ...defaultMobileSize, ...mobileSize };
73
+ }
74
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, observe ? /* @__PURE__ */ React.createElement(ResizeHandler, {
75
+ observe,
76
+ onResize
77
+ }) : null, isMobile ? /* @__PURE__ */ React.createElement(Resizable, {
78
+ style: {
79
+ position: "absolute"
80
+ },
81
+ enable: {
82
+ top: isMobileResizable,
83
+ right: false,
84
+ bottom: false,
85
+ left: false,
86
+ topRight: false,
87
+ bottomRight: false,
88
+ bottomLeft: false,
89
+ topLeft: false
90
+ },
91
+ maxHeight: mobileSize && resizableMobileSize.maximalHeight,
92
+ minHeight: mobileSize && resizableMobileSize.minimalHeight,
93
+ handleComponent: {
94
+ top: /* @__PURE__ */ React.createElement("div", {
95
+ className: "tm-overlay-handler"
96
+ }, "\u2014")
97
+ },
98
+ onResizeStart,
99
+ onResizeStop,
100
+ handleStyles: {
101
+ top: {
102
+ top: "-20px",
103
+ height: "20px",
104
+ padding: "20px 0",
105
+ width: "100%",
106
+ display: "flex",
107
+ alignItems: "center",
108
+ justifyContent: "center"
109
+ }
110
+ },
111
+ size: resizableMobileSize.size,
112
+ defaultSize: mobileSize && resizableMobileSize.defaultSize,
113
+ className: `tm-overlay-mobile${className ? ` ${className}` : ""}`
114
+ }, /* @__PURE__ */ React.createElement("div", {
115
+ className: "tm-overlay-mobile-content"
116
+ }, children)) : /* @__PURE__ */ React.createElement("div", {
117
+ className: `tm-overlay${className ? ` ${className}` : ""}`
118
+ }, children));
119
+ };
120
+ Overlay.propTypes = propTypes;
121
+ Overlay.defaultProps = defaultProps;
122
+ export default Overlay;
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Overlay/Overlay.js"],
4
+ "sourcesContent": ["import React, { Component, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { Resizable } from 're-resizable';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /**\n * CSS class added to container.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the overlay.\n */\n children: PropTypes.node,\n\n /**\n * Observed element to define screen size.\n */\n observe: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.node,\n PropTypes.instanceOf(Component),\n PropTypes.shape({ current: PropTypes.node }),\n PropTypes.shape({ current: PropTypes.instanceOf(Component) }),\n ]),\n\n /**\n * Deactivate the ability to resize the overlay on mobile.\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n isMobileResizable: PropTypes.bool,\n\n /**\n * Size parameters to the Resizable component on mobile.\n * Pass following prop to re-resizable component: 'size', 'defaultSize', 'minHeight' & 'maxHeight'\n * (https://github.com/bokuweb/re-resizable)\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n mobileSize: PropTypes.shape({\n minimalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n defaultSize: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n size: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n }),\n\n /**\n * Minimal width to consider the observed as mobile.\n * Default is 768px.\n */\n thresholdWidthForMobile: PropTypes.number,\n\n /**\n * Callback when stop resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStop: PropTypes.func,\n\n /**\n * Callback when start resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStart: PropTypes.func,\n};\n\nconst defaultMobileSize = {\n defaultSize: {\n width: '100%',\n height: '25%',\n },\n size: undefined,\n maximalHeight: '100%',\n minimalHeight: '25%',\n};\n\nconst defaultProps = {\n className: null,\n children: null,\n observe: null,\n isMobileResizable: true,\n mobileSize: defaultMobileSize,\n thresholdWidthForMobile: 768,\n onResizeStop: () => {},\n onResizeStart: () => {},\n};\n\n/**\n * The Overlay component creates a resizable, swipable overlay <div\\>\n */\nconst Overlay = ({\n observe,\n className,\n children,\n isMobileResizable,\n mobileSize,\n onResizeStop,\n onResizeStart,\n thresholdWidthForMobile,\n}) => {\n const [isMobile, setIsMobile] = useState();\n\n const onResize = (entries) => {\n for (let i = 0; i < entries.length; i += 1) {\n const { width } = entries[i].contentRect;\n setIsMobile(width <= thresholdWidthForMobile);\n }\n };\n\n let resizableMobileSize;\n if (mobileSize) {\n resizableMobileSize = { ...defaultMobileSize, ...mobileSize };\n }\n\n return (\n <>\n {observe ? <ResizeHandler observe={observe} onResize={onResize} /> : null}\n {isMobile ? (\n <Resizable\n style={{\n position: 'absolute',\n }}\n enable={{\n top: isMobileResizable,\n right: false,\n bottom: false,\n left: false,\n topRight: false,\n bottomRight: false,\n bottomLeft: false,\n topLeft: false,\n }}\n maxHeight={mobileSize && resizableMobileSize.maximalHeight}\n minHeight={mobileSize && resizableMobileSize.minimalHeight}\n handleComponent={{\n top: <div className=\"tm-overlay-handler\">&mdash;</div>,\n }}\n onResizeStart={onResizeStart}\n onResizeStop={onResizeStop}\n handleStyles={{\n top: {\n top: '-20px',\n height: '20px',\n padding: '20px 0',\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n }}\n size={resizableMobileSize.size}\n defaultSize={mobileSize && resizableMobileSize.defaultSize}\n className={`tm-overlay-mobile${className ? ` ${className}` : ''}`}\n >\n <div className=\"tm-overlay-mobile-content\">{children}</div>\n </Resizable>\n ) : (\n <div className={`tm-overlay${className ? ` ${className}` : ''}`}>\n {children}\n </div>\n )}\n </>\n );\n};\n\nOverlay.propTypes = propTypes;\nOverlay.defaultProps = defaultProps;\n\nexport default Overlay;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,SAAS,iBAAiB;AAC1B,OAAO,mBAAmB;AAE1B,MAAM,YAAY;AAAA,EAIhB,WAAW,UAAU;AAAA,EAKrB,UAAU,UAAU;AAAA,EAKpB,SAAS,UAAU,UAAU;AAAA,IAC3B,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU,WAAW,SAAS;AAAA,IAC9B,UAAU,MAAM,EAAE,SAAS,UAAU,KAAK,CAAC;AAAA,IAC3C,UAAU,MAAM,EAAE,SAAS,UAAU,WAAW,SAAS,EAAE,CAAC;AAAA,EAC9D,CAAC;AAAA,EAMD,mBAAmB,UAAU;AAAA,EAQ7B,YAAY,UAAU,MAAM;AAAA,IAC1B,eAAe,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACvE,eAAe,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IACvE,aAAa,UAAU,MAAM;AAAA,MAC3B,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,MAChE,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC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,IACA,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,SAAS;AAAA,IACX;AAAA,IACA,WAAW,cAAc,oBAAoB;AAAA,IAC7C,WAAW,cAAc,oBAAoB;AAAA,IAC7C,iBAAiB;AAAA,MACf,KAAK,oCAAC;AAAA,QAAI,WAAU;AAAA,SAAqB,QAAO;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,MACZ,KAAK;AAAA,QACH,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,IACA,MAAM,oBAAoB;AAAA,IAC1B,aAAa,cAAc,oBAAoB;AAAA,IAC/C,WAAW,oBAAoB,YAAY,IAAI,cAAc;AAAA,KAE7D,oCAAC;AAAA,IAAI,WAAU;AAAA,KAA6B,QAAS,CACvD,IAEA,oCAAC;AAAA,IAAI,WAAW,aAAa,YAAY,IAAI,cAAc;AAAA,KACxD,QACH,CAEJ;AAEJ;AAEA,QAAQ,YAAY;AACpB,QAAQ,eAAe;AAEvB,eAAe;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./Overlay";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Overlay/index.js"],
4
+ "sourcesContent": ["export { default } from './Overlay';\n"],
5
+ "mappings": "AAAA,wBAAwB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,206 @@
1
+ import { PureComponent } from "react";
2
+ import PropTypes from "prop-types";
3
+ import qs from "query-string";
4
+ import OLMap from "ol/Map";
5
+ import { unByKey } from "ol/Observable";
6
+ import { Layer, getLayersAsFlatArray } from "mobility-toolbox-js/ol";
7
+ const propTypes = {
8
+ history: PropTypes.shape({
9
+ replace: PropTypes.func
10
+ }),
11
+ layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
12
+ map: PropTypes.instanceOf(OLMap),
13
+ params: PropTypes.object,
14
+ coordinateDecimals: PropTypes.number,
15
+ isLayerHidden: PropTypes.func,
16
+ isBaseLayer: PropTypes.func,
17
+ replace: PropTypes.func
18
+ };
19
+ const defaultProps = {
20
+ history: null,
21
+ replace: null,
22
+ layers: [],
23
+ map: null,
24
+ params: {},
25
+ coordinateDecimals: 2,
26
+ isLayerHidden: () => {
27
+ return false;
28
+ },
29
+ isBaseLayer: (layer) => {
30
+ return layer.get("isBaseLayer");
31
+ }
32
+ };
33
+ class Permalink extends PureComponent {
34
+ constructor(props) {
35
+ super(props);
36
+ this.state = { revision: 0 };
37
+ this.onMoveEndRef = null;
38
+ this.onPropertyChangeKeys = [];
39
+ }
40
+ componentDidMount() {
41
+ const { map, layers, isLayerHidden, isBaseLayer } = this.props;
42
+ if (map) {
43
+ this.moveEndRef = map.on("moveend", () => {
44
+ this.onMapMoved();
45
+ });
46
+ }
47
+ if (layers) {
48
+ const urlParams = qs.parse(window.location.search);
49
+ if (urlParams.layers) {
50
+ const visibleLayers = urlParams.layers.split(",");
51
+ getLayersAsFlatArray(layers).forEach((l) => {
52
+ if (visibleLayers.includes(l.key)) {
53
+ if (l.setVisible) {
54
+ l.setVisible(true);
55
+ } else {
56
+ l.visible = true;
57
+ }
58
+ } else if (!isBaseLayer(l) && !isLayerHidden(l) && !l.children.some((ll) => {
59
+ return ll.visible;
60
+ })) {
61
+ if (l.setVisible) {
62
+ l.setVisible(false);
63
+ } else {
64
+ l.visible = false;
65
+ }
66
+ }
67
+ });
68
+ }
69
+ const visibleBaseLayer = (urlParams.baselayers || "").split(",")[0];
70
+ if (visibleBaseLayer) {
71
+ getLayersAsFlatArray(layers).filter(isBaseLayer).forEach((baseLayer) => {
72
+ const visible = baseLayer.key === visibleBaseLayer;
73
+ if (baseLayer.setVisible) {
74
+ baseLayer.setVisible(visible);
75
+ } else {
76
+ baseLayer.visible = visible;
77
+ }
78
+ });
79
+ }
80
+ this.updateLayers();
81
+ }
82
+ }
83
+ componentDidUpdate(prevProps, prevState) {
84
+ const { map, layers } = this.props;
85
+ const { revision } = this.state;
86
+ if (layers !== prevProps.layers || revision !== prevState.revision) {
87
+ this.updateLayers();
88
+ }
89
+ if (map !== prevProps.map) {
90
+ unByKey(this.moveEndRef);
91
+ this.moveEndRef = map.on("moveend", () => {
92
+ return this.onMapMoved();
93
+ });
94
+ }
95
+ this.updateHistory();
96
+ }
97
+ componentWillUnmount() {
98
+ const { map } = this.props;
99
+ if (map) {
100
+ unByKey(this.moveEndRef);
101
+ }
102
+ unByKey(this.onPropertyChangeKeys);
103
+ this.onPropertyChangeKeys = [];
104
+ }
105
+ onMapMoved() {
106
+ const { map } = this.props;
107
+ const mapView = map.getView();
108
+ const center = mapView.getCenter();
109
+ const params = {};
110
+ if (center !== void 0 && center[0] !== void 0 && center[1] !== void 0) {
111
+ params.x = this.roundCoord(center[0]);
112
+ params.y = this.roundCoord(center[1]);
113
+ }
114
+ this.setState({
115
+ ...params,
116
+ z: +`${Math.round(`${parseFloat(mapView.getZoom())}e+2`)}e-2`
117
+ });
118
+ }
119
+ roundCoord(val) {
120
+ const { coordinateDecimals } = this.props;
121
+ return parseFloat(val.toFixed(coordinateDecimals));
122
+ }
123
+ updateLayers() {
124
+ const { layers, isLayerHidden, isBaseLayer } = this.props;
125
+ const { revision } = this.state;
126
+ unByKey(this.onPropertyChangeKeys);
127
+ this.onPropertyChangeKeys = getLayersAsFlatArray(layers).map((layer) => {
128
+ return layer.on("change:visible", () => {
129
+ this.setState({ revision: revision + 1 });
130
+ });
131
+ });
132
+ let layersParam;
133
+ if (layers.length) {
134
+ layersParam = getLayersAsFlatArray(layers).filter((l) => {
135
+ const children = l.children || [];
136
+ const allChildrenHidden = children.every((child) => {
137
+ return isLayerHidden(child);
138
+ });
139
+ const hasVisibleChildren = children.some((child) => {
140
+ return child.visible;
141
+ });
142
+ return !isBaseLayer(l) && !isLayerHidden(l) && l.visible && (!hasVisibleChildren || allChildrenHidden);
143
+ }).map((l) => {
144
+ return l.key;
145
+ }).join();
146
+ }
147
+ let baseLayersParam;
148
+ const baseLayers = getLayersAsFlatArray(layers).filter(isBaseLayer);
149
+ if (baseLayers.length) {
150
+ const visibleBaseLayers = (baseLayers.filter((l) => {
151
+ return l.visible;
152
+ }) || []).reverse();
153
+ const nonVisibleBaseLayers = baseLayers.filter((l) => {
154
+ return !l.visible;
155
+ }) || [];
156
+ baseLayersParam = [...visibleBaseLayers, ...nonVisibleBaseLayers].sort((a, b) => {
157
+ if (a.visible === b.visible) {
158
+ return 0;
159
+ }
160
+ if (a.visible && !b.visible) {
161
+ return -1;
162
+ }
163
+ return 1;
164
+ }).map((l) => {
165
+ return l.key;
166
+ }).join();
167
+ }
168
+ this.setState({
169
+ layers: layersParam,
170
+ baselayers: baseLayersParam
171
+ });
172
+ }
173
+ updateHistory() {
174
+ const { params, history, replace } = this.props;
175
+ const oldParams = qs.parse(window.location.search);
176
+ const parameters = { ...oldParams, ...this.state, ...params };
177
+ delete parameters.revision;
178
+ Object.entries(parameters).forEach(([key, value]) => {
179
+ if (value === void 0 || value === null) {
180
+ delete parameters[key];
181
+ }
182
+ });
183
+ const qStr = encodeURI(qs.stringify(parameters, { encode: false }));
184
+ const search = qStr ? `?${qStr}` : "";
185
+ if (!qStr && window.location.search || qStr && search !== window.location.search) {
186
+ if (replace) {
187
+ replace({ parameters, search });
188
+ } else if (history) {
189
+ history.replace({ search });
190
+ } else {
191
+ const { hash } = window.location;
192
+ window.history.replaceState(
193
+ void 0,
194
+ void 0,
195
+ `${search}${hash || ""}`
196
+ );
197
+ }
198
+ }
199
+ }
200
+ render() {
201
+ return null;
202
+ }
203
+ }
204
+ Permalink.propTypes = propTypes;
205
+ Permalink.defaultProps = defaultProps;
206
+ export default Permalink;