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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
import { Map } from 'mapbox-gl';
|
|
3
|
+
import { getMapboxMapCopyrights, getMapboxRender } from '../../common/utils';
|
|
4
|
+
import MapGlLayer from './MapGlLayer';
|
|
5
|
+
/**
|
|
6
|
+
* A class representing Mapboxlayer to display on BasicMap
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { MapboxLayer } from 'mobility-toolbox-js/ol';
|
|
10
|
+
*
|
|
11
|
+
* const layer = new MapboxLayer({
|
|
12
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json',
|
|
13
|
+
* apikey: 'yourApiKey',
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
17
|
+
* @extends {Layer}
|
|
18
|
+
*/
|
|
19
|
+
export default class MapboxLayer extends MapGlLayer {
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the layer and listen to feature clicks.
|
|
22
|
+
* @param {ol/Map~Map} map
|
|
23
|
+
*/
|
|
24
|
+
attachToMap(map) {
|
|
25
|
+
super.attachToMap(map);
|
|
26
|
+
if (!this.map) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.olListenersKeys.push(this.map.on('change:size', () => {
|
|
30
|
+
try {
|
|
31
|
+
if (this.mbMap) {
|
|
32
|
+
this.mbMap.resize();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
// ignore render errors
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.warn(err);
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create the mapbox map.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
loadMbMap() {
|
|
47
|
+
var _a;
|
|
48
|
+
// If the map hasn't been resized, the center could be [NaN,NaN].
|
|
49
|
+
// We set default good value for the mapbox map, to avoid the app crashes.
|
|
50
|
+
let [x, y] = ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().getCenter()) || [];
|
|
51
|
+
if (!x || !y) {
|
|
52
|
+
x = 0;
|
|
53
|
+
y = 0;
|
|
54
|
+
}
|
|
55
|
+
// Options the last render run did happen. If something changes
|
|
56
|
+
// we have to render again
|
|
57
|
+
/** @private */
|
|
58
|
+
this.renderState = {
|
|
59
|
+
center: [x, y],
|
|
60
|
+
zoom: undefined,
|
|
61
|
+
rotation: undefined,
|
|
62
|
+
visible: undefined,
|
|
63
|
+
opacity: undefined,
|
|
64
|
+
size: [0, 0],
|
|
65
|
+
};
|
|
66
|
+
super.loadMbMap();
|
|
67
|
+
if (!this.mbMap) {
|
|
68
|
+
// mbMap could ne bull if the map is not in the dom yet.
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.mbMap.once('load', () => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
if (!this.mbMap) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.mbMap.resize();
|
|
77
|
+
/** @private */
|
|
78
|
+
this.copyrights = getMapboxMapCopyrights(this.mbMap) || [];
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
(_b = (_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.setAttributions(this.copyrights);
|
|
81
|
+
});
|
|
82
|
+
const mapboxCanvas = this.mbMap.getCanvas();
|
|
83
|
+
if (mapboxCanvas) {
|
|
84
|
+
if (this.options.tabIndex) {
|
|
85
|
+
mapboxCanvas.setAttribute('tabindex', `${this.options.tabIndex}`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// With a tabIndex='-1' the mouse events works but the map is not focused when we click on it
|
|
89
|
+
// so we remove completely the tabIndex attribute.
|
|
90
|
+
mapboxCanvas.removeAttribute('tabindex');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getOlLayerRender() {
|
|
95
|
+
return getMapboxRender(this);
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line class-methods-use-this
|
|
98
|
+
getMapboxMapClass() {
|
|
99
|
+
return Map;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a copy of the MapboxLayer.
|
|
103
|
+
* @param {Object} newOptions Options to override
|
|
104
|
+
* @return {MapboxLayer} A MapboxLayer
|
|
105
|
+
*/
|
|
106
|
+
clone(newOptions) {
|
|
107
|
+
return new MapboxLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Feature, Map } from 'ol';
|
|
2
|
+
import { Coordinate } from 'ol/coordinate';
|
|
3
|
+
import { ObjectEvent } from 'ol/Object';
|
|
4
|
+
import { AnyMapboxLayer, LayerGetFeatureInfoResponse } from '../../types';
|
|
5
|
+
import Layer, { OlLayerOptions } from './Layer';
|
|
6
|
+
import { FilterFunction } from '../../common/typedefs';
|
|
7
|
+
export type MapboxStyleLayerOptions = OlLayerOptions & {
|
|
8
|
+
beforeId?: string;
|
|
9
|
+
mapboxLayer?: AnyMapboxLayer;
|
|
10
|
+
styleLayer?: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
styleLayers?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}[];
|
|
16
|
+
styleLayersFilter?: FilterFunction;
|
|
17
|
+
filters?: FilterFunction | {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}[];
|
|
20
|
+
queryRenderedLayersFilter?: FilterFunction;
|
|
21
|
+
};
|
|
22
|
+
export type StyleLayer = {
|
|
23
|
+
id?: string;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Layer for visualizing a specific set of layer from a MapboxLayer.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { MapboxLayer, MapboxStyleLayer } from 'mobility-toolbox-js/ol';
|
|
31
|
+
*
|
|
32
|
+
* const mapboxLayer = new MapboxLayer({
|
|
33
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json?key=[yourApiKey]',
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* const layer = new MapboxStyleLayer({
|
|
37
|
+
* mapboxLayer: mapboxLayer,
|
|
38
|
+
* styleLayersFilter: () => {},
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
42
|
+
* @extends {Layer}
|
|
43
|
+
*/
|
|
44
|
+
declare class MapboxStyleLayer extends Layer {
|
|
45
|
+
beforeId?: string;
|
|
46
|
+
mapboxLayer?: AnyMapboxLayer;
|
|
47
|
+
styleLayersFilter?: FilterFunction;
|
|
48
|
+
queryRenderedLayersFilter?: FilterFunction;
|
|
49
|
+
selectedFeatures?: Feature[];
|
|
50
|
+
highlightedFeatures?: Feature[];
|
|
51
|
+
styleLayer?: StyleLayer;
|
|
52
|
+
styleLayers: StyleLayer[];
|
|
53
|
+
addDynamicFilters?: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Constructor.
|
|
56
|
+
*
|
|
57
|
+
* @param {Object} options
|
|
58
|
+
* @param {MapboxLayer} [options.mapboxLayer] The MapboxLayer to use.
|
|
59
|
+
* @param {Function} [options.styleLayersFilter] Filter function to decide which style layer to display.
|
|
60
|
+
*/
|
|
61
|
+
constructor(options: MapboxStyleLayerOptions);
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the layer.
|
|
64
|
+
* @param {ol/Map~Map} map the mapbox map.
|
|
65
|
+
* @override
|
|
66
|
+
*/
|
|
67
|
+
attachToMap(map: Map): void;
|
|
68
|
+
/**
|
|
69
|
+
* Terminate the layer.
|
|
70
|
+
* @override
|
|
71
|
+
*/
|
|
72
|
+
detachFromMap(): void;
|
|
73
|
+
/** @private */
|
|
74
|
+
addStyleLayers(): void;
|
|
75
|
+
/** @private */
|
|
76
|
+
removeStyleLayers(): void;
|
|
77
|
+
/**
|
|
78
|
+
* On Mapbox map load callback function. Add style layers and dynaimc filters.
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
onLoad(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Request feature information for a given coordinate.
|
|
84
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
85
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
86
|
+
*/
|
|
87
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Set filter that determines which features should be rendered in a style layer.
|
|
90
|
+
* @param {mapboxgl.filter} filter Determines which features should be rendered in a style layer.
|
|
91
|
+
*/
|
|
92
|
+
setFilter(filter: {
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
}): void;
|
|
95
|
+
setFeatureState(features: Feature[], state: {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}): void;
|
|
98
|
+
/**
|
|
99
|
+
* Set if features are hovered or not.
|
|
100
|
+
* @param {Array<ol/Feature~Feature>} features
|
|
101
|
+
* @param {boolean} state Is the feature hovered
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
setHoverState(features: Feature[], state: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* Select a list of features.
|
|
107
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
select(features?: Feature[]): void;
|
|
111
|
+
/**
|
|
112
|
+
* Highlight a list of features.
|
|
113
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
highlight(features?: Feature[]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Apply visibility to style layers that fits the styleLayersFilter function.
|
|
119
|
+
* @param {Event} evt Layer's event that has called the function.
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
applyLayoutVisibility(evt?: ObjectEvent): void;
|
|
123
|
+
/**
|
|
124
|
+
* Create a copy of the MapboxStyleLayer.
|
|
125
|
+
* @param {Object} newOptions Options to override.
|
|
126
|
+
* @return {MapboxStyleLayer} A MapboxStyleLayer.
|
|
127
|
+
*/
|
|
128
|
+
clone(newOptions: MapboxStyleLayerOptions): MapboxStyleLayer;
|
|
129
|
+
}
|
|
130
|
+
export default MapboxStyleLayer;
|
|
131
|
+
//# sourceMappingURL=MapboxStyleLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapboxStyleLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapboxStyleLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACpC,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,OAAO,CAAC,EAAE,cAAc,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;IACpD,yBAAyB,CAAC,EAAE,cAAc,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,gBAAiB,SAAQ,KAAK;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,WAAW,CAAC,EAAE,cAAc,CAAC;IAE7B,iBAAiB,CAAC,EAAE,cAAc,CAAC;IAEnC,yBAAyB,CAAC,EAAE,cAAc,CAAC;IAE3C,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC;IAE7B,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC;IAEhC,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,WAAW,EAAE,UAAU,EAAE,CAAC;IAE1B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAE/B;;;;;;OAMG;gBACS,OAAO,EAAE,uBAAuB;IAsF5C;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG;IAoDpB;;;OAGG;IACH,aAAa;IASb,eAAe;IACf,cAAc;IAgBd,eAAe;IACf,iBAAiB;IAcjB;;;OAGG;IACH,MAAM;IAmBN;;;;OAIG;IACH,0BAA0B,CACxB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,2BAA2B,CAAC;IAkCvC;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAcxC,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAmClE;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO;IAIjD;;;;OAIG;IACH,MAAM,CAAC,QAAQ,GAAE,OAAO,EAAO;IAM/B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,GAAE,OAAO,EAAO;IAkBlC;;;;OAIG;IAEH,qBAAqB,CAAC,GAAG,CAAC,EAAE,WAAW;IAwCvC;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,uBAAuB;CAG1C;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import Layer from './Layer';
|
|
2
|
+
/**
|
|
3
|
+
* Layer for visualizing a specific set of layer from a MapboxLayer.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { MapboxLayer, MapboxStyleLayer } from 'mobility-toolbox-js/ol';
|
|
7
|
+
*
|
|
8
|
+
* const mapboxLayer = new MapboxLayer({
|
|
9
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json?key=[yourApiKey]',
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* const layer = new MapboxStyleLayer({
|
|
13
|
+
* mapboxLayer: mapboxLayer,
|
|
14
|
+
* styleLayersFilter: () => {},
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
18
|
+
* @extends {Layer}
|
|
19
|
+
*/
|
|
20
|
+
class MapboxStyleLayer extends Layer {
|
|
21
|
+
/**
|
|
22
|
+
* Constructor.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} options
|
|
25
|
+
* @param {MapboxLayer} [options.mapboxLayer] The MapboxLayer to use.
|
|
26
|
+
* @param {Function} [options.styleLayersFilter] Filter function to decide which style layer to display.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super(options);
|
|
30
|
+
/**
|
|
31
|
+
* MapboxLayer provided for the style Layer.
|
|
32
|
+
* @type {MapboxLayer}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
this.mapboxLayer = options.mapboxLayer;
|
|
36
|
+
/**
|
|
37
|
+
* Define if the layer has data to display in the current mapbox layer.
|
|
38
|
+
*/
|
|
39
|
+
this.disabled = false;
|
|
40
|
+
/**
|
|
41
|
+
* Function to filter features to be displayed.
|
|
42
|
+
* @type {function}
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
this.styleLayersFilter = options.styleLayersFilter;
|
|
46
|
+
/**
|
|
47
|
+
* Mapbox style layer id where to add the style layers.
|
|
48
|
+
* See [mapbox.map.addLayer](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addlayer) documentation.
|
|
49
|
+
* @type {String}
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
this.beforeId = options.beforeId;
|
|
53
|
+
/**
|
|
54
|
+
* Function to query the rendered features.
|
|
55
|
+
* @type {function}
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
this.queryRenderedLayersFilter = options.queryRenderedLayersFilter;
|
|
59
|
+
/**
|
|
60
|
+
* Array of features to highlight.
|
|
61
|
+
* @type {Array<ol/Feature~Feature>}
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
this.highlightedFeatures = [];
|
|
65
|
+
/**
|
|
66
|
+
* Array of selected features.
|
|
67
|
+
* @type {Array<ol/Feature~Feature>}
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
this.selectedFeatures = [];
|
|
71
|
+
/**
|
|
72
|
+
* Array of mapbox style layers to add.
|
|
73
|
+
* @type {Array<mapboxgl.styleLayer>}
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
this.styleLayers =
|
|
77
|
+
(options.styleLayer ? [options.styleLayer] : options.styleLayers) || [];
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
this.addStyleLayers = this.addStyleLayers.bind(this);
|
|
82
|
+
/**
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
this.onLoad = this.onLoad.bind(this);
|
|
86
|
+
if (options.filters) {
|
|
87
|
+
/** @private */
|
|
88
|
+
this.addDynamicFilters = () => {
|
|
89
|
+
this.setFilter(typeof options.filters === 'function'
|
|
90
|
+
? options.filters(this)
|
|
91
|
+
: options.filters);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (!this.styleLayersFilter && this.styleLayers) {
|
|
95
|
+
this.styleLayersFilter = (styleLayer) => {
|
|
96
|
+
var _a;
|
|
97
|
+
return !!((_a = this.styleLayers) === null || _a === void 0 ? void 0 : _a.find((sl) => styleLayer.id === sl.id));
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Initialize the layer.
|
|
103
|
+
* @param {ol/Map~Map} map the mapbox map.
|
|
104
|
+
* @override
|
|
105
|
+
*/
|
|
106
|
+
attachToMap(map) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (this.mapboxLayer && !this.mapboxLayer.map) {
|
|
109
|
+
(_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.attachToMap(map);
|
|
110
|
+
}
|
|
111
|
+
super.attachToMap(map);
|
|
112
|
+
if (!this.map || !this.mapboxLayer) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Apply the initial visibiltity.
|
|
116
|
+
const { mbMap } = this.mapboxLayer;
|
|
117
|
+
if (!mbMap) {
|
|
118
|
+
// If the mbMap is not yet created because the map has no target yet, we
|
|
119
|
+
// relaunch the initialisation when it's the case.
|
|
120
|
+
this.olListenersKeys.push(this.map.on('change:target', () => {
|
|
121
|
+
this.attachToMap(map);
|
|
122
|
+
}));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// mbMap.loaded() and mbMap.isStyleLoaded() are reliable only on the first call of init.
|
|
126
|
+
// On the next call (when a topic change for example), these functions returns false because
|
|
127
|
+
// the style is being modified.
|
|
128
|
+
// That's why we rely on a property instead for the next calls.
|
|
129
|
+
if (this.mapboxLayer.loaded || mbMap.isStyleLoaded() || mbMap.loaded()) {
|
|
130
|
+
this.onLoad();
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
mbMap.once('load', this.onLoad);
|
|
134
|
+
}
|
|
135
|
+
// Apply the visibiltity when layer's visibility change.
|
|
136
|
+
this.olListenersKeys.push(
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
this.on('change:visible', (evt) => {
|
|
139
|
+
// Once the map is loaded we can apply visiblity without waiting
|
|
140
|
+
// the style. Mapbox take care of the application of style changes.
|
|
141
|
+
this.applyLayoutVisibility(evt);
|
|
142
|
+
}));
|
|
143
|
+
this.olListenersKeys.push(
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
this.mapboxLayer.on('load', () => {
|
|
146
|
+
this.onLoad();
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Terminate the layer.
|
|
151
|
+
* @override
|
|
152
|
+
*/
|
|
153
|
+
detachFromMap() {
|
|
154
|
+
var _a;
|
|
155
|
+
if ((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap) {
|
|
156
|
+
const { mbMap } = this.mapboxLayer;
|
|
157
|
+
mbMap.off('load', this.onLoad);
|
|
158
|
+
this.removeStyleLayers();
|
|
159
|
+
}
|
|
160
|
+
super.detachFromMap();
|
|
161
|
+
}
|
|
162
|
+
/** @private */
|
|
163
|
+
addStyleLayers() {
|
|
164
|
+
var _a;
|
|
165
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const { mbMap } = this.mapboxLayer;
|
|
169
|
+
this.styleLayers.forEach((styleLayer) => {
|
|
170
|
+
const { id, source } = styleLayer;
|
|
171
|
+
if (mbMap.getSource(source) && id && !mbMap.getLayer(id)) {
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
mbMap.addLayer(styleLayer, this.beforeId);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
this.applyLayoutVisibility();
|
|
177
|
+
}
|
|
178
|
+
/** @private */
|
|
179
|
+
removeStyleLayers() {
|
|
180
|
+
var _a;
|
|
181
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const { mbMap } = this.mapboxLayer;
|
|
185
|
+
this.styleLayers.forEach((styleLayer) => {
|
|
186
|
+
const { id } = styleLayer;
|
|
187
|
+
if (id && mbMap.getLayer(id)) {
|
|
188
|
+
mbMap.removeLayer(id);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* On Mapbox map load callback function. Add style layers and dynaimc filters.
|
|
194
|
+
* @private
|
|
195
|
+
*/
|
|
196
|
+
onLoad() {
|
|
197
|
+
var _a;
|
|
198
|
+
this.addStyleLayers();
|
|
199
|
+
if (this.addDynamicFilters) {
|
|
200
|
+
this.addDynamicFilters();
|
|
201
|
+
}
|
|
202
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const { mbMap } = this.mapboxLayer;
|
|
206
|
+
const style = mbMap.getStyle();
|
|
207
|
+
if (style && this.styleLayersFilter) {
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
const styles = style.layers.filter(this.styleLayersFilter);
|
|
210
|
+
this.disabled = !styles.length;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Request feature information for a given coordinate.
|
|
215
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
216
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
217
|
+
*/
|
|
218
|
+
getFeatureInfoAtCoordinate(coordinate) {
|
|
219
|
+
var _a;
|
|
220
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
221
|
+
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
222
|
+
}
|
|
223
|
+
const { mbMap } = this.mapboxLayer;
|
|
224
|
+
// Ignore the getFeatureInfo until the mapbox map is loaded
|
|
225
|
+
if (!mbMap.isStyleLoaded()) {
|
|
226
|
+
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
227
|
+
}
|
|
228
|
+
// We query features only on style layers used by this layer.
|
|
229
|
+
let layers = this.styleLayers || [];
|
|
230
|
+
if (this.styleLayersFilter) {
|
|
231
|
+
// @ts-ignore
|
|
232
|
+
layers = mbMap.getStyle().layers.filter(this.styleLayersFilter);
|
|
233
|
+
}
|
|
234
|
+
if (this.queryRenderedLayersFilter) {
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
layers = mbMap.getStyle().layers.filter(this.queryRenderedLayersFilter);
|
|
237
|
+
}
|
|
238
|
+
return this.mapboxLayer
|
|
239
|
+
.getFeatureInfoAtCoordinate(coordinate, {
|
|
240
|
+
layers: layers.map((layer) => layer && layer.id),
|
|
241
|
+
validate: false,
|
|
242
|
+
})
|
|
243
|
+
.then((featureInfo) => {
|
|
244
|
+
return Object.assign(Object.assign({}, featureInfo), { layer: this });
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Set filter that determines which features should be rendered in a style layer.
|
|
249
|
+
* @param {mapboxgl.filter} filter Determines which features should be rendered in a style layer.
|
|
250
|
+
*/
|
|
251
|
+
setFilter(filter) {
|
|
252
|
+
var _a;
|
|
253
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const { mbMap } = this.mapboxLayer;
|
|
257
|
+
this.styleLayers.forEach(({ id }) => {
|
|
258
|
+
if (id && filter && mbMap.getLayer(id)) {
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
mbMap.setFilter(id, filter);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
setFeatureState(features, state) {
|
|
265
|
+
var _a;
|
|
266
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const { mbMap } = this.mapboxLayer;
|
|
270
|
+
if (!features || !mbMap) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
features.forEach((feature) => {
|
|
274
|
+
const { source, sourceLayer } = feature.get('mapboxFeature') || {};
|
|
275
|
+
if ((!source && !sourceLayer) || !feature.getId()) {
|
|
276
|
+
if (!feature.getId()) {
|
|
277
|
+
// eslint-disable-next-line no-console
|
|
278
|
+
console.warn("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.", feature.getId(), feature.getProperties());
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
mbMap.setFeatureState({
|
|
283
|
+
id: feature.getId(),
|
|
284
|
+
source,
|
|
285
|
+
sourceLayer,
|
|
286
|
+
}, state);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set if features are hovered or not.
|
|
291
|
+
* @param {Array<ol/Feature~Feature>} features
|
|
292
|
+
* @param {boolean} state Is the feature hovered
|
|
293
|
+
* @private
|
|
294
|
+
*/
|
|
295
|
+
setHoverState(features, state) {
|
|
296
|
+
this.setFeatureState(features, { hover: state });
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Select a list of features.
|
|
300
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
|
|
301
|
+
* @private
|
|
302
|
+
*/
|
|
303
|
+
select(features = []) {
|
|
304
|
+
this.setHoverState(this.selectedFeatures || [], false);
|
|
305
|
+
this.selectedFeatures = features;
|
|
306
|
+
this.setHoverState(this.selectedFeatures || [], true);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Highlight a list of features.
|
|
310
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
313
|
+
highlight(features = []) {
|
|
314
|
+
var _a;
|
|
315
|
+
// Filter out selected features
|
|
316
|
+
const filtered = ((_a = this.highlightedFeatures) === null || _a === void 0 ? void 0 : _a.filter((feature) => !(this.selectedFeatures || [])
|
|
317
|
+
.map((feat) => feat.getId())
|
|
318
|
+
.includes(feature.getId()))) || [];
|
|
319
|
+
// Remove previous highlight
|
|
320
|
+
this.setHoverState(filtered, false);
|
|
321
|
+
this.highlightedFeatures = features;
|
|
322
|
+
// Add highlight
|
|
323
|
+
this.setHoverState(this.highlightedFeatures, true);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Apply visibility to style layers that fits the styleLayersFilter function.
|
|
327
|
+
* @param {Event} evt Layer's event that has called the function.
|
|
328
|
+
* @private
|
|
329
|
+
*/
|
|
330
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
331
|
+
applyLayoutVisibility(evt) {
|
|
332
|
+
var _a;
|
|
333
|
+
const { visible } = this;
|
|
334
|
+
const filterFunc = this.styleLayersFilter;
|
|
335
|
+
if (!((_a = this.mapboxLayer) === null || _a === void 0 ? void 0 : _a.mbMap)) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const { mbMap } = this.mapboxLayer;
|
|
339
|
+
const style = mbMap.getStyle();
|
|
340
|
+
if (!style) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (filterFunc) {
|
|
344
|
+
const visibilityValue = visible ? 'visible' : 'none';
|
|
345
|
+
const layers = style.layers || [];
|
|
346
|
+
for (let i = 0; i < layers.length; i += 1) {
|
|
347
|
+
const styleLayer = layers[i];
|
|
348
|
+
if (filterFunc(styleLayer)) {
|
|
349
|
+
if (mbMap.getLayer(styleLayer.id)) {
|
|
350
|
+
mbMap.setLayoutProperty(styleLayer.id, 'visibility', visibilityValue);
|
|
351
|
+
if (this.get('minZoom') || this.get('maxZoom')) {
|
|
352
|
+
mbMap.setLayerZoomRange(styleLayer.id, this.get('minZoom') ? this.get('minZoom') - 1 : 0, // mapbox zoom = ol zoom - 1
|
|
353
|
+
this.get('maxZoom') ? this.get('maxZoom') - 1 : 24);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Create a copy of the MapboxStyleLayer.
|
|
362
|
+
* @param {Object} newOptions Options to override.
|
|
363
|
+
* @return {MapboxStyleLayer} A MapboxStyleLayer.
|
|
364
|
+
*/
|
|
365
|
+
clone(newOptions) {
|
|
366
|
+
return new MapboxStyleLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
export default MapboxStyleLayer;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Map } from 'maplibre-gl';
|
|
2
|
-
import { getMaplibreRender } from '../../common/utils';
|
|
3
2
|
import MapGlLayer, { MapGlLayerOptions } from './MapGlLayer';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* A class representing MaplibreLayer to display on BasicMap
|
|
7
5
|
*
|
|
@@ -17,23 +15,14 @@ import MapGlLayer, { MapGlLayerOptions } from './MapGlLayer';
|
|
|
17
15
|
* @extends {Layer}
|
|
18
16
|
*/
|
|
19
17
|
export default class MaplibreLayer extends MapGlLayer {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Create a copy of the MapboxLayer.
|
|
33
|
-
* @param {Object} newOptions Options to override
|
|
34
|
-
* @return {MapboxLayer} A MapboxLayer
|
|
35
|
-
*/
|
|
36
|
-
clone(newOptions: MapGlLayerOptions) {
|
|
37
|
-
return new MaplibreLayer({ ...this.options, ...newOptions });
|
|
38
|
-
}
|
|
18
|
+
mbMap?: maplibregl.Map;
|
|
19
|
+
getOlLayerRender(): import("ol/layer/Layer").RenderFunction;
|
|
20
|
+
getMapboxMapClass(): typeof Map;
|
|
21
|
+
/**
|
|
22
|
+
* Create a copy of the MapboxLayer.
|
|
23
|
+
* @param {Object} newOptions Options to override
|
|
24
|
+
* @return {MapboxLayer} A MapboxLayer
|
|
25
|
+
*/
|
|
26
|
+
clone(newOptions: MapGlLayerOptions): MaplibreLayer;
|
|
39
27
|
}
|
|
28
|
+
//# sourceMappingURL=MaplibreLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaplibreLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MaplibreLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;IAEvB,gBAAgB;IAKhB,iBAAiB;IAIjB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,iBAAiB;CAGpC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Map } from 'maplibre-gl';
|
|
2
|
+
import { getMaplibreRender } from '../../common/utils';
|
|
3
|
+
import MapGlLayer from './MapGlLayer';
|
|
4
|
+
/**
|
|
5
|
+
* A class representing MaplibreLayer to display on BasicMap
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { MaplibreLayer } from 'mobility-toolbox-js/ol';
|
|
9
|
+
*
|
|
10
|
+
* const layer = new MaplibreLayer({
|
|
11
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json',
|
|
12
|
+
* apikey: 'yourApiKey',
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
16
|
+
* @extends {Layer}
|
|
17
|
+
*/
|
|
18
|
+
export default class MaplibreLayer extends MapGlLayer {
|
|
19
|
+
getOlLayerRender() {
|
|
20
|
+
return getMaplibreRender(this);
|
|
21
|
+
}
|
|
22
|
+
// eslint-disable-next-line class-methods-use-this
|
|
23
|
+
getMapboxMapClass() {
|
|
24
|
+
return Map;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a copy of the MapboxLayer.
|
|
28
|
+
* @param {Object} newOptions Options to override
|
|
29
|
+
* @return {MapboxLayer} A MapboxLayer
|
|
30
|
+
*/
|
|
31
|
+
clone(newOptions) {
|
|
32
|
+
return new MaplibreLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
33
|
+
}
|
|
34
|
+
}
|