mobility-toolbox-js 2.0.0-beta.8 → 2.0.0-beta.80

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 (447) hide show
  1. package/api/RealtimeAPI.d.ts +279 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +466 -0
  4. package/api/RoutingAPI.d.ts +37 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +35 -0
  7. package/api/StopsAPI.d.ts +38 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +36 -0
  10. package/api/index.d.ts +4 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +3 -0
  13. package/api/typedefs.d.ts +179 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/{src/api/tralis → api}/typedefs.js +4 -10
  16. package/common/api/HttpAPI.d.ts +31 -0
  17. package/common/api/HttpAPI.d.ts.map +1 -0
  18. package/common/api/HttpAPI.js +57 -0
  19. package/common/api/WebSocketAPI.d.ts +153 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +341 -0
  22. package/common/controls/ControlCommon.d.ts +76 -0
  23. package/common/controls/ControlCommon.d.ts.map +1 -0
  24. package/common/controls/ControlCommon.js +150 -0
  25. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  26. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  27. package/common/controls/CopyrightControlCommon.js +34 -0
  28. package/common/controls/StopFinderControlCommon.d.ts +55 -0
  29. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  30. package/common/controls/StopFinderControlCommon.js +144 -0
  31. package/common/index.d.ts +3 -0
  32. package/common/index.d.ts.map +1 -0
  33. package/common/index.js +2 -0
  34. package/common/layers/LayerCommon.d.ts +94 -0
  35. package/common/layers/LayerCommon.d.ts.map +1 -0
  36. package/common/layers/LayerCommon.js +244 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +776 -0
  40. package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
  41. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  42. package/common/mixins/UserInteractionsLayerMixin.js +241 -0
  43. package/common/styles/index.d.ts +5 -0
  44. package/common/styles/index.d.ts.map +1 -0
  45. package/common/styles/index.js +4 -0
  46. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  47. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  48. package/common/styles/realtimeDefaultStyle.js +275 -0
  49. package/{src/common/styles/trackerDelayStyle.js → common/styles/realtimeDelayStyle.d.ts} +4 -9
  50. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDelayStyle.js +13 -0
  52. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  53. package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeHeadingStyle.js +85 -0
  55. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -0
  58. package/common/typedefs.d.ts +111 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +52 -0
  61. package/common/utils/compareDepartures.d.ts +11 -0
  62. package/common/utils/compareDepartures.d.ts.map +1 -0
  63. package/common/utils/compareDepartures.js +35 -0
  64. package/common/utils/createCanvas.d.ts +10 -0
  65. package/common/utils/createCanvas.d.ts.map +1 -0
  66. package/common/utils/createCanvas.js +27 -0
  67. package/common/utils/createRealtimeFilters.d.ts +13 -0
  68. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  69. package/common/utils/createRealtimeFilters.js +74 -0
  70. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  71. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  72. package/common/utils/debounceDeparturesMessages.js +24 -0
  73. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  74. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  75. package/common/utils/debounceWebsocketMessages.js +29 -0
  76. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  77. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  78. package/common/utils/getLayersAsFlatArray.js +15 -0
  79. package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
  80. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  81. package/common/utils/getMapboxMapCopyrights.js +30 -0
  82. package/common/utils/getMapboxRender.d.ts +7 -0
  83. package/common/utils/getMapboxRender.d.ts.map +1 -0
  84. package/common/utils/getMapboxRender.js +87 -0
  85. package/common/utils/getMaplibreRender.d.ts +7 -0
  86. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  87. package/common/utils/getMaplibreRender.js +38 -0
  88. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  89. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  90. package/common/utils/getRealtimeModeSuffix.js +7 -0
  91. package/common/utils/getUrlWithParams.d.ts +9 -0
  92. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  93. package/common/utils/getUrlWithParams.js +18 -0
  94. package/common/utils/getVehiclePosition.d.ts +16 -0
  95. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  96. package/common/utils/getVehiclePosition.js +72 -0
  97. package/common/utils/index.d.ts +17 -0
  98. package/common/utils/index.d.ts.map +1 -0
  99. package/common/utils/index.js +17 -0
  100. package/common/utils/realtimeConfig.d.ts +49 -0
  101. package/common/utils/realtimeConfig.d.ts.map +1 -0
  102. package/common/utils/realtimeConfig.js +173 -0
  103. package/common/utils/removeDuplicate.d.ts +10 -0
  104. package/common/utils/removeDuplicate.d.ts.map +1 -0
  105. package/common/utils/removeDuplicate.js +15 -0
  106. package/common/utils/renderTrajectories.d.ts +17 -0
  107. package/common/utils/renderTrajectories.d.ts.map +1 -0
  108. package/common/utils/renderTrajectories.js +110 -0
  109. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  110. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  111. package/common/utils/sortAndFilterDepartures.js +58 -0
  112. package/common/utils/sortByDelay.d.ts +3 -0
  113. package/common/utils/sortByDelay.d.ts.map +1 -0
  114. package/common/utils/sortByDelay.js +20 -0
  115. package/common/utils/timeUtils.d.ts +24 -0
  116. package/common/utils/timeUtils.d.ts.map +1 -0
  117. package/{src/common → common}/utils/timeUtils.js +13 -18
  118. package/iife.d.ts +3 -0
  119. package/iife.d.ts.map +1 -0
  120. package/{src/iife.js → iife.js} +1 -3
  121. package/index.d.ts +10 -0
  122. package/index.d.ts.map +1 -0
  123. package/index.js +10 -0
  124. package/mapbox/controls/CopyrightControl.d.ts +29 -0
  125. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  126. package/mapbox/controls/CopyrightControl.js +48 -0
  127. package/mapbox/controls/index.d.ts +2 -0
  128. package/mapbox/controls/index.d.ts.map +1 -0
  129. package/mapbox/index.d.ts +6 -0
  130. package/mapbox/index.d.ts.map +1 -0
  131. package/{src/mapbox → mapbox}/index.js +1 -0
  132. package/mapbox/layers/Layer.d.ts +59 -0
  133. package/mapbox/layers/Layer.d.ts.map +1 -0
  134. package/mapbox/layers/Layer.js +101 -0
  135. package/mapbox/layers/RealtimeLayer.d.ts +181 -0
  136. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  137. package/mapbox/layers/RealtimeLayer.js +276 -0
  138. package/mapbox/layers/index.d.ts +3 -0
  139. package/mapbox/layers/index.d.ts.map +1 -0
  140. package/mapbox/layers/index.js +2 -0
  141. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  142. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  143. package/mapbox/utils/getMercatorResolution.js +18 -0
  144. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  145. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  146. package/mapbox/utils/getSourceCoordinates.js +27 -0
  147. package/mapbox/utils/index.d.ts +3 -0
  148. package/mapbox/utils/index.d.ts.map +1 -0
  149. package/mapbox/utils/index.js +2 -0
  150. package/mbt.js +59981 -0
  151. package/mbt.js.map +7 -0
  152. package/mbt.min.js +1084 -0
  153. package/mbt.min.js.map +7 -0
  154. package/ol/controls/CopyrightControl.d.ts +31 -0
  155. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  156. package/ol/controls/CopyrightControl.js +68 -0
  157. package/ol/controls/RoutingControl.d.ts +193 -0
  158. package/ol/controls/RoutingControl.d.ts.map +1 -0
  159. package/ol/controls/RoutingControl.js +631 -0
  160. package/ol/controls/StopFinderControl.d.ts +30 -0
  161. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  162. package/{src/ol → ol}/controls/StopFinderControl.js +10 -16
  163. package/ol/controls/index.d.ts +4 -0
  164. package/ol/controls/index.d.ts.map +1 -0
  165. package/ol/index.d.ts +6 -0
  166. package/ol/index.d.ts.map +1 -0
  167. package/ol/layers/Layer.d.ts +86 -0
  168. package/ol/layers/Layer.d.ts.map +1 -0
  169. package/ol/layers/Layer.js +160 -0
  170. package/ol/layers/MapGlLayer.d.ts +67 -0
  171. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  172. package/ol/layers/MapGlLayer.js +218 -0
  173. package/ol/layers/MapboxLayer.d.ts +50 -0
  174. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  175. package/ol/layers/MapboxLayer.js +109 -0
  176. package/ol/layers/MapboxStyleLayer.d.ts +129 -0
  177. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  178. package/ol/layers/MapboxStyleLayer.js +374 -0
  179. package/ol/layers/MaplibreLayer.d.ts +28 -0
  180. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  181. package/ol/layers/MaplibreLayer.js +34 -0
  182. package/ol/layers/RealtimeLayer.d.ts +202 -0
  183. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  184. package/ol/layers/RealtimeLayer.js +340 -0
  185. package/ol/layers/RoutingLayer.d.ts +34 -0
  186. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  187. package/ol/layers/RoutingLayer.js +85 -0
  188. package/ol/layers/VectorLayer.d.ts +25 -0
  189. package/ol/layers/VectorLayer.d.ts.map +1 -0
  190. package/ol/layers/VectorLayer.js +38 -0
  191. package/ol/layers/WMSLayer.d.ts +42 -0
  192. package/ol/layers/WMSLayer.d.ts.map +1 -0
  193. package/ol/layers/WMSLayer.js +88 -0
  194. package/ol/layers/index.d.ts +9 -0
  195. package/ol/layers/index.d.ts.map +1 -0
  196. package/{src/ol → ol}/layers/index.js +1 -1
  197. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  198. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  199. package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
  200. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  201. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  202. package/ol/styles/fullTrajectoryStyle.js +44 -0
  203. package/ol/styles/index.d.ts +3 -0
  204. package/ol/styles/index.d.ts.map +1 -0
  205. package/package.json +96 -189
  206. package/setupTests.d.ts +2 -0
  207. package/setupTests.d.ts.map +1 -0
  208. package/{src/setupTests.js → setupTests.js} +13 -2
  209. package/types/common.d.ts +122 -0
  210. package/types/index.d.ts +11 -0
  211. package/types/realtime.d.ts +320 -0
  212. package/types/routing.d.ts +206 -0
  213. package/types/stops.d.ts +143 -0
  214. package/.babelrc +0 -6
  215. package/.esdoc.json +0 -17
  216. package/.eslintignore +0 -1
  217. package/.github/workflows/conventional-pr-title.yml +0 -21
  218. package/.github/workflows/cypress.yml +0 -29
  219. package/.github/workflows/nodejs.yml +0 -28
  220. package/.husky/commit-msg +0 -4
  221. package/.husky/post-checkout +0 -4
  222. package/.husky/post-merge +0 -4
  223. package/.husky/post-rebase +0 -4
  224. package/.husky/pre-commit +0 -4
  225. package/.neutrinorc.js +0 -176
  226. package/.nvmrc +0 -1
  227. package/CHANGELOG.md +0 -10
  228. package/LICENSE +0 -21
  229. package/README.md +0 -23
  230. package/__mocks__/mapbox-gl.js +0 -81
  231. package/__mocks__/maplibre-gl.js +0 -81
  232. package/commitlint.config.js +0 -1
  233. package/cypress/fixtures/example.json +0 -5
  234. package/cypress/integration/examples/api.spec.js +0 -7
  235. package/cypress/integration/examples/examples.spec.js +0 -7
  236. package/cypress/integration/examples/navigation.spec.js +0 -29
  237. package/cypress/plugins/index.js +0 -21
  238. package/cypress/support/commands.js +0 -25
  239. package/cypress/support/index.js +0 -20
  240. package/cypress.json +0 -4
  241. package/data/fetchRoute.json +0 -292
  242. package/data/fetchTrajectories.json +0 -18
  243. package/data/fetchTrajectoryById.json +0 -3
  244. package/data/fetchTrajectoryStations.json +0 -18
  245. package/data/stopsSearch.json +0 -15
  246. package/documentation.yml +0 -4
  247. package/esdoc/README.md +0 -27
  248. package/esdoc/plugins/MyPlugin.js +0 -69
  249. package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
  250. package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
  251. package/esdoc/plugins/externals-plugin/externals.js +0 -96
  252. package/global-setup.js +0 -3
  253. package/index.html +0 -0
  254. package/indexweb.html +0 -49
  255. package/jest.config.js +0 -5
  256. package/pull_request_template.md +0 -17
  257. package/renovate.json +0 -4
  258. package/scripts/read-pkg-json.js +0 -22
  259. package/src/api/index.js +0 -3
  260. package/src/api/routing/RoutingAPI.js +0 -44
  261. package/src/api/routing/RoutingAPI.test.js +0 -41
  262. package/src/api/stops/StopsAPI.js +0 -41
  263. package/src/api/stops/StopsAPI.test.js +0 -34
  264. package/src/api/tralis/TralisAPI.js +0 -731
  265. package/src/api/tralis/TralisAPI.test.js +0 -75
  266. package/src/api/tralis/TralisAPIUtils.js +0 -73
  267. package/src/api/tralis/WebSocketConnector.js +0 -338
  268. package/src/api/tralis/WebSocketConnector.test.js +0 -356
  269. package/src/assets/Lato-Black.ttf +0 -0
  270. package/src/assets/Lato-BlackItalic.ttf +0 -0
  271. package/src/assets/Lato-Bold.ttf +0 -0
  272. package/src/assets/Lato-BoldItalic.ttf +0 -0
  273. package/src/assets/Lato-Italic.ttf +0 -0
  274. package/src/assets/Lato-Light.ttf +0 -0
  275. package/src/assets/Lato-LightItalic.ttf +0 -0
  276. package/src/assets/Lato-Regular.ttf +0 -0
  277. package/src/assets/Lato-Thin.ttf +0 -0
  278. package/src/assets/Lato-ThinItalic.ttf +0 -0
  279. package/src/assets/OFL.txt +0 -93
  280. package/src/common/Tracker.js +0 -197
  281. package/src/common/api/api.js +0 -64
  282. package/src/common/api/api.test.js +0 -68
  283. package/src/common/controls/Control.js +0 -146
  284. package/src/common/controls/Control.test.js +0 -98
  285. package/src/common/index.js +0 -5
  286. package/src/common/layers/Layer.js +0 -404
  287. package/src/common/layers/Layer.test.js +0 -585
  288. package/src/common/mixins/CopyrightMixin.js +0 -48
  289. package/src/common/mixins/SearchMixin.js +0 -176
  290. package/src/common/mixins/TralisLayerMixin.js +0 -930
  291. package/src/common/styles/index.js +0 -4
  292. package/src/common/styles/trackerDefaultStyle.js +0 -333
  293. package/src/common/styles/trackerSimpleStyle.js +0 -22
  294. package/src/common/trackerConfig.js +0 -190
  295. package/src/common/trackerConfig.test.js +0 -25
  296. package/src/common/typedefs.js +0 -23
  297. package/src/common/utils/createTrackerFilters.js +0 -87
  298. package/src/common/utils/createTrackerFilters.test.js +0 -95
  299. package/src/common/utils/getMapboxMapCopyrights.js +0 -32
  300. package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
  301. package/src/common/utils/getMapboxStyleUrl.js +0 -32
  302. package/src/common/utils/getVehiclePosition.js +0 -72
  303. package/src/common/utils/index.js +0 -5
  304. package/src/common/utils/removeDuplicate.js +0 -22
  305. package/src/common/utils/removeDuplicate.test.js +0 -22
  306. package/src/common/utils/sortByDelay.js +0 -23
  307. package/src/common/utils/timeUtils.test.js +0 -16
  308. package/src/doc/App.js +0 -116
  309. package/src/doc/App.scss +0 -51
  310. package/src/doc/_redirects +0 -2
  311. package/src/doc/components/CodeSandboxButton.js +0 -103
  312. package/src/doc/components/Documentation.js +0 -40
  313. package/src/doc/components/Esdoc/Anchor.js +0 -57
  314. package/src/doc/components/Esdoc/ClassDoc.js +0 -272
  315. package/src/doc/components/Esdoc/DeprecatedHTML.js +0 -16
  316. package/src/doc/components/Esdoc/DetailDocs.js +0 -281
  317. package/src/doc/components/Esdoc/DetailHTML.js +0 -33
  318. package/src/doc/components/Esdoc/DirectSubclassHTML.js +0 -30
  319. package/src/doc/components/Esdoc/DocBuilderUtils.js +0 -694
  320. package/src/doc/components/Esdoc/DocLinkHTML.js +0 -62
  321. package/src/doc/components/Esdoc/DocsLinkHTML.js +0 -38
  322. package/src/doc/components/Esdoc/Esdoc.js +0 -63
  323. package/src/doc/components/Esdoc/EsdocContent.js +0 -51
  324. package/src/doc/components/Esdoc/EsdocNavigation.js +0 -13
  325. package/src/doc/components/Esdoc/EsdocSearch.js +0 -81
  326. package/src/doc/components/Esdoc/ExperimentalHTML.js +0 -17
  327. package/src/doc/components/Esdoc/ExtendsChainHTML.js +0 -32
  328. package/src/doc/components/Esdoc/FileDocLinkHTML.js +0 -60
  329. package/src/doc/components/Esdoc/IdentifiersDoc.js +0 -113
  330. package/src/doc/components/Esdoc/IndirectSubclassHTML.js +0 -30
  331. package/src/doc/components/Esdoc/InheritedSummaryDoc.js +0 -70
  332. package/src/doc/components/Esdoc/InheritedSummaryHTML.js +0 -38
  333. package/src/doc/components/Esdoc/MixinClassesHTML.js +0 -29
  334. package/src/doc/components/Esdoc/NavDoc.js +0 -112
  335. package/src/doc/components/Esdoc/OverrideMethod.js +0 -44
  336. package/src/doc/components/Esdoc/OverrideMethodDescription.js +0 -35
  337. package/src/doc/components/Esdoc/Properties.js +0 -89
  338. package/src/doc/components/Esdoc/README.md +0 -45
  339. package/src/doc/components/Esdoc/SignatureHTML.js +0 -123
  340. package/src/doc/components/Esdoc/SingleDoc.js +0 -31
  341. package/src/doc/components/Esdoc/SummaryDoc.js +0 -160
  342. package/src/doc/components/Esdoc/SummaryHTML.js +0 -96
  343. package/src/doc/components/Esdoc/TypeDocLinkHTML.js +0 -249
  344. package/src/doc/components/Esdoc/css/identifiers.css +0 -38
  345. package/src/doc/components/Esdoc/css/search.css +0 -76
  346. package/src/doc/components/Esdoc/css/style.css +0 -603
  347. package/src/doc/components/Esdoc/index.js +0 -7
  348. package/src/doc/components/Example.js +0 -153
  349. package/src/doc/components/Examples.js +0 -183
  350. package/src/doc/components/Home.js +0 -106
  351. package/src/doc/components/TrackerExample.js +0 -38
  352. package/src/doc/examples/assets/tralis-live-map/index.js +0 -11
  353. package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  354. package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  355. package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  356. package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  357. package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  358. package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  359. package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  360. package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  361. package/src/doc/examples/assets/tralis-live-map/unknown.svg +0 -107
  362. package/src/doc/examples/mb-copyright.html +0 -26
  363. package/src/doc/examples/mb-copyright.js +0 -37
  364. package/src/doc/examples/mb-tracker.html +0 -1
  365. package/src/doc/examples/mb-tracker.js +0 -39
  366. package/src/doc/examples/mb-tracker.md +0 -1
  367. package/src/doc/examples/mb-tralis.html +0 -1
  368. package/src/doc/examples/mb-tralis.js +0 -34
  369. package/src/doc/examples/ol-copyright.html +0 -26
  370. package/src/doc/examples/ol-copyright.js +0 -43
  371. package/src/doc/examples/ol-mapbox-layer.html +0 -1
  372. package/src/doc/examples/ol-mapbox-layer.js +0 -28
  373. package/src/doc/examples/ol-mapbox-layer.md +0 -0
  374. package/src/doc/examples/ol-mapbox-style-layer.html +0 -12
  375. package/src/doc/examples/ol-mapbox-style-layer.js +0 -44
  376. package/src/doc/examples/ol-query.html +0 -32
  377. package/src/doc/examples/ol-query.js +0 -83
  378. package/src/doc/examples/ol-routing.html +0 -26
  379. package/src/doc/examples/ol-routing.js +0 -59
  380. package/src/doc/examples/ol-routing.md +0 -1
  381. package/src/doc/examples/ol-stop-finder.html +0 -15
  382. package/src/doc/examples/ol-stop-finder.js +0 -31
  383. package/src/doc/examples/ol-stop-finder.md +0 -1
  384. package/src/doc/examples/ol-tracker.html +0 -1
  385. package/src/doc/examples/ol-tracker.js +0 -44
  386. package/src/doc/examples/ol-tracker.md +0 -1
  387. package/src/doc/examples/ol-tralis.html +0 -5
  388. package/src/doc/examples/ol-tralis.js +0 -57
  389. package/src/doc/examples/tralis-live-map.html +0 -1
  390. package/src/doc/examples/tralis-live-map.js +0 -51
  391. package/src/doc/examples/tralis-live-map.md +0 -3
  392. package/src/doc/examples.js +0 -107
  393. package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
  394. package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
  395. package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
  396. package/src/doc/img/examples/mapbox.jpg +0 -0
  397. package/src/doc/img/examples/mapbox_style.jpg +0 -0
  398. package/src/doc/img/examples/ol-copyright.png +0 -0
  399. package/src/doc/img/examples/query_objects.jpg +0 -0
  400. package/src/doc/img/examples/routing.jpg +0 -0
  401. package/src/doc/img/examples/simple_map.jpg +0 -0
  402. package/src/doc/img/examples/stops.jpg +0 -0
  403. package/src/doc/img/favico.ico +0 -0
  404. package/src/doc/index.js +0 -21
  405. package/src/index.js +0 -10
  406. package/src/mapbox/controls/CopyrightControl.js +0 -58
  407. package/src/mapbox/layers/Layer.js +0 -118
  408. package/src/mapbox/layers/Layer.test.js +0 -202
  409. package/src/mapbox/layers/TralisLayer.js +0 -329
  410. package/src/mapbox/layers/TralisLayer.test.js +0 -40
  411. package/src/mapbox/layers/index.js +0 -2
  412. package/src/mapbox/utils.js +0 -46
  413. package/src/ol/README.md +0 -0
  414. package/src/ol/controls/CopyrightControl.js +0 -80
  415. package/src/ol/controls/CopyrightControl.test.js +0 -211
  416. package/src/ol/controls/RoutingControl.js +0 -752
  417. package/src/ol/controls/RoutingControl.test.js +0 -216
  418. package/src/ol/controls/StopFinderControl.test.js +0 -59
  419. package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  420. package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  421. package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  422. package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  423. package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  424. package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  425. package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  426. package/src/ol/layers/Layer.js +0 -193
  427. package/src/ol/layers/Layer.test.js +0 -197
  428. package/src/ol/layers/MapboxLayer.js +0 -378
  429. package/src/ol/layers/MapboxLayer.test.js +0 -186
  430. package/src/ol/layers/MapboxStyleLayer.js +0 -417
  431. package/src/ol/layers/MapboxStyleLayer.test.js +0 -262
  432. package/src/ol/layers/MaplibreLayer.js +0 -280
  433. package/src/ol/layers/RoutingLayer.js +0 -91
  434. package/src/ol/layers/RoutingLayer.test.js +0 -49
  435. package/src/ol/layers/TralisLayer.js +0 -359
  436. package/src/ol/layers/TralisLayer.test.js +0 -97
  437. package/src/ol/layers/VectorLayer.js +0 -43
  438. package/src/ol/layers/VectorLayer.test.js +0 -98
  439. package/src/ol/layers/WMSLayer.js +0 -80
  440. package/src/ol/layers/WMSLayer.test.js +0 -84
  441. package/src/ol/styles/fullTrajectoryDelayStyle.js +0 -35
  442. package/src/ol/styles/fullTrajectoryStyle.js +0 -51
  443. package/webpack.config.js +0 -6
  444. /package/{src/mapbox → mapbox}/controls/index.js +0 -0
  445. /package/{src/ol → ol}/controls/index.js +0 -0
  446. /package/{src/ol → ol}/index.js +0 -0
  447. /package/{src/ol → ol}/styles/index.js +0 -0
@@ -1,417 +0,0 @@
1
- /* eslint-disable no-param-reassign */
2
- import Layer from './Layer';
3
-
4
- /**
5
- * Layer for visualizing a specific set of layer from a MapboxLayer.
6
- *
7
- * @example
8
- * import { MapboxLayer, MapboxStyleLayer } from 'mobility-toolbox-js/ol';
9
- *
10
- * const mapboxLayer = new MapboxLayer({
11
- * url: 'https://maps.geops.io/styles/travic_v2/style.json?key=[yourApiKey]',
12
- * });
13
- *
14
- * const layer = new MapboxStyleLayer({
15
- * mapboxLayer: mapboxLayer,
16
- * styleLayersFilter: () => {},
17
- * });
18
- *
19
- * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
20
- * @extends {Layer}
21
- */
22
- class MapboxStyleLayer extends Layer {
23
- /**
24
- * Constructor.
25
- *
26
- * @param {Object} options
27
- * @param {MapboxLayer} [options.mapboxLayer] The MapboxLayer to use.
28
- * @param {Function} [options.styleLayersFilter] Filter function to decide which style layer to display.
29
- */
30
- constructor(options = {}) {
31
- super(options);
32
-
33
- /**
34
- * MapboxLayer provided for the style Layer.
35
- * @type {MapboxLayer}
36
- * @private
37
- */
38
- this.mapboxLayer = options.mapboxLayer;
39
-
40
- /**
41
- * Define if the layer has data to display in the current mapbox layer.
42
- */
43
- this.disabled = false;
44
-
45
- /**
46
- * Function to filter features to be displayed.
47
- * @type {function}
48
- * @private
49
- */
50
- this.styleLayersFilter = options.styleLayersFilter;
51
-
52
- /**
53
- * Mapbox style layer id where to add the style layers.
54
- * See [mapbox.map.addLayer](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addlayer) documentation.
55
- * @type {String}
56
- * @private
57
- */
58
- this.beforeId = options.beforeId;
59
-
60
- /**
61
- * Function to filter features for getFeatureInfoAtCoordinate method.
62
- * @type {function}
63
- * @private
64
- */
65
- this.featureInfoFilter = options.featureInfoFilter || ((obj) => obj);
66
-
67
- /**
68
- * Function to query the rendered features.
69
- * @type {function}
70
- * @private
71
- */
72
- this.queryRenderedLayersFilter = options.queryRenderedLayersFilter;
73
-
74
- /**
75
- * Array of features to highlight.
76
- * @type {Array<ol/Feature~Feature>}
77
- * @private
78
- */
79
- this.highlightedFeatures = [];
80
-
81
- /**
82
- * Array of selected features.
83
- * @type {Array<ol/Feature~Feature>}
84
- * @private
85
- */
86
- this.selectedFeatures = [];
87
-
88
- /**
89
- * Array of mapbox style layers to add.
90
- * @type {Array<mapboxgl.styleLayer>}
91
- * @private
92
- */
93
- this.styleLayers =
94
- (options.styleLayer ? [options.styleLayer] : options.styleLayers) || [];
95
-
96
- /**
97
- * @private
98
- */
99
- this.addStyleLayers = this.addStyleLayers.bind(this);
100
-
101
- /**
102
- * @private
103
- */
104
- this.onLoad = this.onLoad.bind(this);
105
- if (options.filters) {
106
- /** @private */
107
- this.addDynamicFilters = () => {
108
- this.setFilter(
109
- typeof options.filters === 'function'
110
- ? options.filters(this)
111
- : options.filters,
112
- );
113
- };
114
- }
115
-
116
- if (!this.styleLayersFilter && this.styleLayers) {
117
- const ids = this.styleLayers.map((s) => s.id);
118
- this.styleLayersFilter = (styleLayer) => ids.includes(styleLayer.id);
119
- }
120
- }
121
-
122
- /**
123
- * Initialize the layer.
124
- * @param {mapboxgl.Map} map the mapbox map.
125
- * @override
126
- */
127
- init(map) {
128
- if (!this.mapboxLayer.map) {
129
- this.mapboxLayer.init(map);
130
- }
131
- super.init(map);
132
-
133
- if (!this.map) {
134
- return;
135
- }
136
-
137
- // Apply the initial visibiltity.
138
- const { mbMap } = this.mapboxLayer;
139
- if (!mbMap) {
140
- // If the mbMap is not yet created because the map has no target yet, we
141
- // relaunch the initialisation when it's the case.
142
- this.olListenersKeys.push(
143
- this.map.on('change:target', () => {
144
- this.init(map);
145
- }),
146
- );
147
-
148
- return;
149
- }
150
-
151
- // mbMap.loaded() and mbMap.isStyleLoaded() are reliable only on the first call of init.
152
- // On the next call (when a topic change for example), these functions returns false because
153
- // the style is being modified.
154
- // That's why we rely on a property instead for the next calls.
155
- if (this.mapboxLayer.loaded || mbMap.isStyleLoaded() || mbMap.loaded()) {
156
- this.onLoad();
157
- } else {
158
- mbMap.once('load', this.onLoad);
159
- }
160
-
161
- // Apply the visibiltity when layer's visibility change.
162
- this.olListenersKeys.push(
163
- this.on('change:visible', (evt) => {
164
- // Once the map is loaded we can apply vsiiblity without waiting
165
- // the style. Mapbox take care of the application of style changes.
166
- this.applyLayoutVisibility(evt);
167
- }),
168
- );
169
-
170
- this.olListenersKeys.push(
171
- this.mapboxLayer.on('load', () => {
172
- this.onLoad();
173
- }),
174
- );
175
- }
176
-
177
- /**
178
- * Terminate the layer.
179
- * @param {mapboxgl.Map} map the mapbox map.
180
- * @override
181
- */
182
- terminate(map) {
183
- const { mbMap } = this.mapboxLayer;
184
- if (mbMap) {
185
- mbMap.off('load', this.onLoad);
186
- this.removeStyleLayers();
187
- }
188
- super.terminate(map);
189
- }
190
-
191
- /** @ignore */
192
- addStyleLayers() {
193
- const { mbMap } = this.mapboxLayer;
194
-
195
- if (!mbMap) {
196
- return;
197
- }
198
-
199
- this.styleLayers.forEach((styleLayer) => {
200
- const { id, source } = styleLayer;
201
- if (mbMap.getSource(source) && !mbMap.getLayer(id)) {
202
- mbMap.addLayer(styleLayer, this.beforeId);
203
- }
204
- });
205
- this.applyLayoutVisibility();
206
- }
207
-
208
- /** @ignore */
209
- removeStyleLayers() {
210
- const { mbMap } = this.mapboxLayer;
211
-
212
- if (!mbMap) {
213
- return;
214
- }
215
-
216
- this.styleLayers.forEach((styleLayer) => {
217
- if (mbMap.getLayer(styleLayer.id)) {
218
- mbMap.removeLayer(styleLayer.id);
219
- }
220
- });
221
- }
222
-
223
- /**
224
- * On Mapbox map load callback function. Add style layers and dynaimc filters.
225
- * @ignore
226
- */
227
- onLoad() {
228
- this.addStyleLayers();
229
-
230
- if (this.addDynamicFilters) {
231
- this.addDynamicFilters();
232
- }
233
-
234
- const { mbMap } = this.mapboxLayer;
235
- const style = mbMap.getStyle();
236
- if (style && this.styleLayersFilter) {
237
- const styles = style.layers.filter(this.styleLayersFilter);
238
- this.disabled = !styles.length;
239
- }
240
- }
241
-
242
- /**
243
- * Request feature information for a given coordinate.
244
- * @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
245
- * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
246
- */
247
- getFeatureInfoAtCoordinate(coordinate) {
248
- const { mbMap } = this.mapboxLayer;
249
-
250
- // Ignore the getFeatureInfo until the mapbox map is loaded
251
- if (!mbMap || !mbMap.isStyleLoaded()) {
252
- return Promise.resolve({ coordinate, features: [], layer: this });
253
- }
254
-
255
- // We query features only on style layers used by this layer.
256
- let layers = this.styleLayers || [];
257
-
258
- if (this.styleLayersFilter) {
259
- layers = mbMap.getStyle().layers.filter(this.styleLayersFilter);
260
- }
261
-
262
- if (this.queryRenderedLayersFilter) {
263
- layers = mbMap.getStyle().layers.filter(this.queryRenderedLayersFilter);
264
- }
265
-
266
- return this.mapboxLayer
267
- .getFeatureInfoAtCoordinate(coordinate, {
268
- layers: layers.map((layer) => layer && layer.id),
269
- validate: false,
270
- })
271
- .then((featureInfo) => {
272
- const features = featureInfo.features.filter((feature) =>
273
- this.featureInfoFilter(feature, this.map.getView().getResolution()),
274
- );
275
- this.highlight(features);
276
- return { ...featureInfo, features, layer: this };
277
- });
278
- }
279
-
280
- /**
281
- * Set filter that determines which features should be rendered in a style layer.
282
- * @param {mapboxgl.filter} filter Determines which features should be rendered in a style layer.
283
- */
284
- setFilter(filter) {
285
- const { mbMap } = this.mapboxLayer;
286
-
287
- if (!mbMap) {
288
- return;
289
- }
290
-
291
- this.styleLayers.forEach(({ id }) => {
292
- if (mbMap.getLayer(id)) {
293
- mbMap.setFilter(id, filter);
294
- }
295
- });
296
- }
297
-
298
- /**
299
- * Set if features are hovered or not.
300
- * @param {Array<ol/Feature~Feature>} features
301
- * @param {boolean} state Is the feature hovered
302
- * @private
303
- */
304
- setHoverState(features, state) {
305
- const { mbMap } = this.mapboxLayer;
306
-
307
- if (!features || !mbMap) {
308
- return;
309
- }
310
-
311
- features.forEach((feature) => {
312
- const { source, sourceLayer } = feature.get('mapboxFeature') || {};
313
- if ((!source && !sourceLayer) || !feature.getId()) {
314
- if (!feature.getId()) {
315
- // eslint-disable-next-line no-console
316
- console.warn(
317
- "No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/mapbox/tippecanoe#adding-calculated-attributes.",
318
- feature.getId(),
319
- feature.getProperties(),
320
- );
321
- }
322
- return;
323
- }
324
-
325
- mbMap.setFeatureState(
326
- {
327
- id: feature.getId(),
328
- source,
329
- sourceLayer,
330
- },
331
- { hover: state },
332
- );
333
- });
334
- }
335
-
336
- /**
337
- * Select a list of features.
338
- * @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
339
- * @private
340
- */
341
- select(features = []) {
342
- this.setHoverState(this.selectedFeatures, false);
343
- this.selectedFeatures = features;
344
- this.setHoverState(this.selectedFeatures, true);
345
- }
346
-
347
- /**
348
- * Highlight a list of features.
349
- * @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
350
- * @private
351
- */
352
- highlight(features = []) {
353
- // Filter out selected features
354
- const filtered = this.highlightedFeatures.filter(
355
- (feature) =>
356
- !this.selectedFeatures
357
- .map((feat) => feat.getId())
358
- .includes(feature.getId()),
359
- );
360
-
361
- // Remove previous highlight
362
- this.setHoverState(filtered, false);
363
- this.highlightedFeatures = features;
364
-
365
- // Add highlight
366
- this.setHoverState(this.highlightedFeatures, true);
367
- }
368
-
369
- /**
370
- * Apply visibility to style layers that fits the styleLayersFilter function.
371
- * @param {Event} evt Layer's event that has called the function.
372
- * @private
373
- */
374
- // eslint-disable-next-line no-unused-vars
375
- applyLayoutVisibility(evt) {
376
- const { visible } = this;
377
- const { mbMap } = this.mapboxLayer;
378
- const filterFunc = this.styleLayersFilter;
379
-
380
- if (!mbMap) {
381
- return;
382
- }
383
-
384
- const style = mbMap.getStyle();
385
-
386
- if (!style) {
387
- return;
388
- }
389
-
390
- if (filterFunc) {
391
- const visibilityValue = visible ? 'visible' : 'none';
392
- for (let i = 0; i < style.layers.length; i += 1) {
393
- const styleLayer = style.layers[i];
394
- if (filterFunc(styleLayer)) {
395
- if (mbMap.getLayer(styleLayer.id)) {
396
- mbMap.setLayoutProperty(
397
- styleLayer.id,
398
- 'visibility',
399
- visibilityValue,
400
- );
401
- }
402
- }
403
- }
404
- }
405
- }
406
-
407
- /**
408
- * Create a copy of the MapboxStyleLayer.
409
- * @param {Object} newOptions Options to override.
410
- * @return {MapboxStyleLayer} A MapboxStyleLayer.
411
- */
412
- clone(newOptions) {
413
- return new MapboxStyleLayer({ ...this.options, ...newOptions });
414
- }
415
- }
416
-
417
- export default MapboxStyleLayer;
@@ -1,262 +0,0 @@
1
- import OlMap from 'ol/Map';
2
- import View from 'ol/View';
3
- import gllib from 'maplibre-gl';
4
- import Layer from './Layer';
5
- import MaplibreLayer from './MaplibreLayer';
6
- import MapboxStyleLayer from './MapboxStyleLayer';
7
-
8
- let source;
9
- let layer;
10
- let map;
11
- let onClick;
12
-
13
- const styleLayer = {
14
- id: 'layer',
15
- };
16
-
17
- describe('MapboxStyleLayer', () => {
18
- beforeEach(() => {
19
- onClick = jest.fn();
20
- source = new MaplibreLayer({
21
- name: 'Layer',
22
- apiKey: false,
23
- });
24
- layer = new MapboxStyleLayer({
25
- name: 'mapbox layer',
26
- visible: true,
27
- mapboxLayer: source,
28
- styleLayer,
29
- onClick,
30
- });
31
- map = new OlMap({
32
- target: document.createElement('div'),
33
- view: new View({ center: [0, 0] }),
34
- });
35
- });
36
-
37
- afterEach(() => {
38
- if (layer.map) {
39
- layer.terminate(map);
40
- }
41
- if (source.map) {
42
- source.terminate(map);
43
- }
44
- });
45
-
46
- test('should be instanced.', () => {
47
- expect(layer).toBeInstanceOf(MapboxStyleLayer);
48
- expect(layer.styleLayers[0]).toBe(styleLayer);
49
- expect(layer.clickCallbacks[0]).toBe(onClick);
50
- });
51
-
52
- test('should not initalized mapbox map.', () => {
53
- layer.init();
54
- expect(layer.mbMap).toBe();
55
- layer.terminate();
56
- });
57
-
58
- test('should initalized mapbox map.', () => {
59
- source.init(map);
60
- layer.init(map);
61
- expect(layer.mapboxLayer.mbMap).toBeInstanceOf(gllib.Map);
62
- layer.terminate();
63
- source.terminate();
64
- });
65
-
66
- test('should add onClick callback.', () => {
67
- const onClick2 = jest.fn();
68
- layer.onClick(onClick2);
69
- expect(layer.clickCallbacks[1]).toBe(onClick2);
70
- });
71
-
72
- test('should called terminate on initalization.', () => {
73
- const spy = jest.spyOn(layer, 'terminate');
74
- layer.init();
75
- expect(spy).toHaveBeenCalledTimes(1);
76
- layer.terminate(map);
77
- });
78
-
79
- test('should return coordinates, features and a layer instance.', async () => {
80
- source.init(map);
81
- layer.init(map);
82
- const data = await layer.getFeatureInfoAtCoordinate([50, 50]);
83
- expect(data.coordinate).toEqual([50, 50]);
84
- expect(data.features).toEqual([]);
85
- expect(data.layer).toBeInstanceOf(MapboxStyleLayer);
86
- layer.terminate(map);
87
- source.terminate(map);
88
- });
89
-
90
- test('should call onClick callback', async () => {
91
- const coordinate = [500, 500];
92
- const features = [];
93
- const evt = { type: 'singleclick', map, coordinate };
94
- layer.init(map);
95
- expect(onClick).toHaveBeenCalledTimes(0);
96
- await map.dispatchEvent(evt);
97
- expect(onClick).toHaveBeenCalledTimes(1);
98
- expect(onClick).toHaveBeenCalledWith(features, layer, coordinate);
99
- layer.terminate();
100
- });
101
-
102
- test('should call super class terminate function.', () => {
103
- layer.init(map);
104
- const spy = jest.spyOn(Layer.prototype, 'terminate');
105
- layer.terminate(map);
106
- expect(spy).toHaveBeenCalledTimes(1);
107
- spy.mockRestore();
108
- });
109
-
110
- test('should call super class terminate if the mapboxLayer associated has been terminated before.', () => {
111
- layer.init(map);
112
- source.terminate(map);
113
- const spy = jest.spyOn(Layer.prototype, 'terminate');
114
- layer.terminate(map);
115
- expect(spy).toHaveBeenCalledTimes(1);
116
- spy.mockRestore();
117
- });
118
-
119
- test('should clone', () => {
120
- const clone = layer.clone({ name: 'clone' });
121
- expect(clone).not.toBe(layer);
122
- expect(clone.name).toBe('clone');
123
- expect(clone).toBeInstanceOf(MapboxStyleLayer);
124
- });
125
-
126
- test('should add layer on load', () => {
127
- const style = { layers: [] };
128
- layer.mapboxLayer.mbMap = {
129
- getStyle: () => style,
130
- getSource: () => ({}),
131
- getLayer: () => null,
132
- setLayoutProperty: () => null,
133
- addLayer: (styleLayerr) => style.layers.push(styleLayerr),
134
- };
135
- layer.onLoad();
136
- expect(style.layers[0]).toBe(styleLayer);
137
- });
138
-
139
- describe('should set disabled property to false on load', () => {
140
- test('when layer uses styleLayer property', () => {
141
- const styles = { layers: [] };
142
- layer.mapboxLayer.mbMap = {
143
- getStyle: () => styles,
144
- getSource: () => ({}),
145
- getLayer: () => null,
146
- setLayoutProperty: () => null,
147
- addLayer: (styleLayerr) => styles.layers.push(styleLayerr),
148
- };
149
- expect(layer).toBeInstanceOf(MapboxStyleLayer);
150
- layer.onLoad();
151
- expect(layer.disabled).toBe(false);
152
- });
153
- });
154
-
155
- describe('should set disabled property to true on load', () => {
156
- test('when layer uses styleLayersFilter property', () => {
157
- const styles = { layers: [styleLayer] };
158
- const layer2 = new MapboxStyleLayer({
159
- name: 'mapbox layer',
160
- mapboxLayer: source,
161
- styleLayersFilter: () => false,
162
- });
163
- layer2.mapboxLayer.mbMap = {
164
- getStyle: () => styles,
165
- getSource: () => ({}),
166
- getLayer: () => null,
167
- setLayoutProperty: () => null,
168
- addLayer: () => ({}),
169
- };
170
- layer2.onLoad();
171
- expect(layer2.disabled).toBe(true);
172
- });
173
- });
174
-
175
- describe('#getFeatureInfoAtCoordinate()', () => {
176
- beforeEach(() => {
177
- source.init(map);
178
- source.mbMap.isStyleLoaded = jest.fn(() => true);
179
- source.mbMap.getSource = jest.fn(() => true);
180
- });
181
- afterEach(() => {
182
- source.mbMap.getSource.mockRestore();
183
- source.mbMap.isStyleLoaded.mockRestore();
184
- });
185
-
186
- test('should request features on layers ids from styleLayers property', () => {
187
- source.mbMap.getStyle = jest.fn(() => ({
188
- layers: [{ id: 'foo' }, { id: 'layer' }, { id: 'bar' }],
189
- }));
190
- layer.init(map);
191
- layer.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
192
- Promise.resolve({ features: [] }),
193
- );
194
- layer.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
195
- expect(layer.mapboxLayer.getFeatureInfoAtCoordinate).toHaveBeenCalledWith(
196
- [0, 0],
197
- { layers: ['layer'], validate: false },
198
- );
199
- layer.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
200
- source.mbMap.getStyle.mockRestore();
201
- });
202
-
203
- test('should request features on layers ids from styleLayersFilter property', () => {
204
- source.mbMap.getStyle = jest.fn(() => ({
205
- layers: [{ id: 'foo' }, { id: 'layer' }, { id: 'bar' }, { id: 'foo2' }],
206
- }));
207
- const layer2 = new MapboxStyleLayer({
208
- name: 'mapbox layer',
209
- visible: true,
210
- mapboxLayer: source,
211
- styleLayer,
212
- styleLayersFilter: ({ id }) => /foo/.test(id),
213
- });
214
- layer2.init(map);
215
- layer2.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
216
- Promise.resolve({ features: [] }),
217
- );
218
- layer2.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
219
- expect(
220
- layer2.mapboxLayer.getFeatureInfoAtCoordinate,
221
- ).toHaveBeenCalledWith([0, 0], {
222
- layers: ['foo', 'foo2'],
223
- validate: false,
224
- });
225
- layer2.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
226
- source.mbMap.getStyle.mockRestore();
227
- });
228
-
229
- test('should request features on layers ids from queryRenderedLayersFilter property', () => {
230
- source.mbMap.getStyle = jest.fn(() => ({
231
- layers: [
232
- { id: 'foo' },
233
- { id: 'bar2' },
234
- { id: 'layer' },
235
- { id: 'bar' },
236
- { id: 'foo2' },
237
- ],
238
- }));
239
- const layer2 = new MapboxStyleLayer({
240
- name: 'mapbox layer',
241
- visible: true,
242
- mapboxLayer: source,
243
- styleLayer,
244
- styleLayersFilter: ({ id }) => /foo/.test(id),
245
- queryRenderedLayersFilter: ({ id }) => /bar/.test(id),
246
- });
247
- layer2.init(map);
248
- layer2.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
249
- Promise.resolve({ features: [] }),
250
- );
251
- layer2.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
252
- expect(
253
- layer2.mapboxLayer.getFeatureInfoAtCoordinate,
254
- ).toHaveBeenCalledWith([0, 0], {
255
- layers: ['bar2', 'bar'],
256
- validate: false,
257
- });
258
- layer2.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
259
- source.mbMap.getStyle.mockRestore();
260
- });
261
- });
262
- });