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