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