mobility-toolbox-js 2.3.10 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/RealtimeAPI.d.ts +290 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +483 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/{src/api → api}/typedefs.js +1 -11
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +288 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +276 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +87 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +183 -0
- package/common/typedefs.d.ts.map +1 -0
- package/{src/common → common}/typedefs.js +1 -1
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +11 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +13 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +28 -0
- package/common/utils/debounceWebsocketMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +30 -0
- package/common/utils/getLayersAsFlatArray.d.ts +4 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +16 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +30 -0
- package/common/utils/getMapboxRender.d.ts +8 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +88 -0
- package/common/utils/getMaplibreRender.d.ts +9 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +40 -0
- package/{src/common/utils/getRealtimeModeSuffix.ts → common/utils/getRealtimeModeSuffix.d.ts} +2 -4
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +72 -0
- package/common/utils/index.d.ts +18 -0
- package/common/utils/index.d.ts.map +1 -0
- package/{src/common → common}/utils/index.js +2 -1
- package/common/utils/realtimeConfig.d.ts +53 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +202 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +15 -0
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +4 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -0
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +39 -0
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/{src/iife.js → iife.js} +1 -3
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/{src/mapbox/controls/CopyrightControl.ts → mapbox/controls/CopyrightControl.js} +21 -26
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +101 -0
- package/mapbox/layers/RealtimeLayer.d.ts +180 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +270 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mbt.js +64822 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1090 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +68 -0
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +631 -0
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/{src/ol/controls/StopFinderControl.ts → ol/controls/StopFinderControl.js} +7 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +174 -0
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +109 -0
- package/ol/layers/MapboxStyleLayer.d.ts +131 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +369 -0
- package/{src/ol/layers/MaplibreLayer.ts → ol/layers/MaplibreLayer.d.ts} +10 -21
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +34 -0
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +332 -0
- package/ol/layers/RoutingLayer.d.ts +35 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +85 -0
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +38 -0
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +88 -0
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/{src/setupTests.js → setupTests.js} +7 -12
- package/.esdoc.js +0 -18
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.fixpackrc +0 -20
- package/.github/workflows/build.yml +0 -16
- package/.github/workflows/conventional-pr-title.yml +0 -16
- package/.github/workflows/cypress.yml +0 -101
- package/.github/workflows/test.yml +0 -17
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.js +0 -10
- package/.nvmrc +0 -1
- package/.prettierrc.js +0 -5
- package/.stylelintrc.js +0 -4
- package/CHANGELOG.md +0 -132
- package/LICENSE +0 -21
- package/MIGRATION-V2.md +0 -248
- package/README.md +0 -42
- package/__mocks__/mapbox-gl.js +0 -81
- package/__mocks__/maplibre-gl.js +0 -81
- package/babel.config.js +0 -9
- package/commitlint.config.js +0 -1
- package/cypress/e2e/examples/api.cy.js +0 -7
- package/cypress/e2e/examples/examples.cy.js +0 -7
- package/cypress/e2e/examples/navigation.cy.js +0 -29
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.ts +0 -15
- package/data/fetchRoute.json +0 -292
- package/data/fetchTrajectories.json +0 -18
- package/data/fetchTrajectoryById.json +0 -3
- package/data/fetchTrajectoryStations.json +0 -18
- package/data/stopsSearch.json +0 -15
- package/dependabot.yml +0 -15
- package/doc/.eslintrc.json +0 -1
- package/doc/README.md +0 -34
- package/doc/next.config.js +0 -16
- package/doc/package.json +0 -41
- package/doc/pages/404.js +0 -5
- package/doc/pages/_app.js +0 -61
- package/doc/pages/_document.js +0 -64
- package/doc/pages/doc/[...slug].js +0 -23
- package/doc/pages/doc.js +0 -23
- package/doc/pages/example/[example].js +0 -52
- package/doc/pages/examples.js +0 -34
- package/doc/pages/index.js +0 -25
- package/doc/public/README.md +0 -15
- package/doc/public/favicon.ico +0 -0
- package/doc/public/static/assets/Lato-Black.ttf +0 -0
- package/doc/public/static/assets/Lato-BlackItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Bold.ttf +0 -0
- package/doc/public/static/assets/Lato-BoldItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Italic.ttf +0 -0
- package/doc/public/static/assets/Lato-Light.ttf +0 -0
- package/doc/public/static/assets/Lato-LightItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Regular.ttf +0 -0
- package/doc/public/static/assets/Lato-Thin.ttf +0 -0
- package/doc/public/static/assets/Lato-ThinItalic.ttf +0 -0
- package/doc/public/static/assets/OFL.txt +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/index.js +0 -11
- package/doc/public/static/examples/assets/tralis-live-map/s1kreis.svg +0 -105
- package/doc/public/static/examples/assets/tralis-live-map/s20kreis.svg +0 -101
- package/doc/public/static/examples/assets/tralis-live-map/s2kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s3kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s4kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s6kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s7kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s8kreis.svg +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/unknown.svg +0 -107
- package/doc/public/static/examples/layers.html +0 -11
- package/doc/public/static/examples/layers.js +0 -97
- package/doc/public/static/examples/mb-copyright.html +0 -26
- package/doc/public/static/examples/mb-copyright.js +0 -37
- package/doc/public/static/examples/mb-tracker.html +0 -1
- package/doc/public/static/examples/mb-tracker.js +0 -40
- package/doc/public/static/examples/mb-tracker.md +0 -1
- package/doc/public/static/examples/mb-tralis.html +0 -1
- package/doc/public/static/examples/mb-tralis.js +0 -34
- package/doc/public/static/examples/ol-copyright.html +0 -26
- package/doc/public/static/examples/ol-copyright.js +0 -43
- package/doc/public/static/examples/ol-mapbox-layer.html +0 -1
- package/doc/public/static/examples/ol-mapbox-layer.js +0 -28
- package/doc/public/static/examples/ol-mapbox-style-layer.html +0 -12
- package/doc/public/static/examples/ol-mapbox-style-layer.js +0 -48
- package/doc/public/static/examples/ol-query.html +0 -32
- package/doc/public/static/examples/ol-query.js +0 -83
- package/doc/public/static/examples/ol-routing.html +0 -26
- package/doc/public/static/examples/ol-routing.js +0 -65
- package/doc/public/static/examples/ol-routing.md +0 -1
- package/doc/public/static/examples/ol-stop-finder.html +0 -15
- package/doc/public/static/examples/ol-stop-finder.js +0 -35
- package/doc/public/static/examples/ol-stop-finder.md +0 -1
- package/doc/public/static/examples/ol-tracker.html +0 -1
- package/doc/public/static/examples/ol-tracker.js +0 -41
- package/doc/public/static/examples/ol-tracker.md +0 -1
- package/doc/public/static/examples/ol-tralis.html +0 -5
- package/doc/public/static/examples/ol-tralis.js +0 -62
- package/doc/public/static/examples/tralis-live-map.html +0 -1
- package/doc/public/static/examples/tralis-live-map.js +0 -67
- package/doc/public/static/examples/tralis-live-map.md +0 -3
- package/doc/public/static/img/live_tracker_mb.jpg +0 -0
- package/doc/public/static/img/live_tracker_munich.jpg +0 -0
- package/doc/public/static/img/live_tracker_ol.jpg +0 -0
- package/doc/public/static/img/mapbox.jpg +0 -0
- package/doc/public/static/img/mapbox_style.jpg +0 -0
- package/doc/public/static/img/ol-copyright.png +0 -0
- package/doc/public/static/img/query_objects.jpg +0 -0
- package/doc/public/static/img/routing.jpg +0 -0
- package/doc/public/static/img/simple_map.jpg +0 -0
- package/doc/public/static/img/stops.jpg +0 -0
- package/doc/public/vercel.svg +0 -4
- package/doc/src/components/CodeSandboxButton.js +0 -102
- package/doc/src/components/Documentation.js +0 -42
- package/doc/src/components/Esdoc/Anchor.js +0 -57
- package/doc/src/components/Esdoc/ClassDoc.js +0 -272
- package/doc/src/components/Esdoc/DeprecatedHTML.js +0 -16
- package/doc/src/components/Esdoc/DetailDocs.js +0 -279
- package/doc/src/components/Esdoc/DetailHTML.js +0 -33
- package/doc/src/components/Esdoc/DirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/DocBuilderUtils.js +0 -697
- package/doc/src/components/Esdoc/DocLinkHTML.js +0 -63
- package/doc/src/components/Esdoc/DocsLinkHTML.js +0 -38
- package/doc/src/components/Esdoc/Esdoc.js +0 -63
- package/doc/src/components/Esdoc/EsdocContent.js +0 -56
- package/doc/src/components/Esdoc/EsdocNavigation.js +0 -13
- package/doc/src/components/Esdoc/EsdocSearch.js +0 -78
- package/doc/src/components/Esdoc/ExperimentalHTML.js +0 -17
- package/doc/src/components/Esdoc/ExtendsChainHTML.js +0 -32
- package/doc/src/components/Esdoc/FileDocLinkHTML.js +0 -62
- package/doc/src/components/Esdoc/IdentifiersDoc.js +0 -113
- package/doc/src/components/Esdoc/IndirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/InheritedSummaryDoc.js +0 -70
- package/doc/src/components/Esdoc/InheritedSummaryHTML.js +0 -38
- package/doc/src/components/Esdoc/MixinClassesHTML.js +0 -29
- package/doc/src/components/Esdoc/NavDoc.js +0 -112
- package/doc/src/components/Esdoc/OverrideMethod.js +0 -44
- package/doc/src/components/Esdoc/OverrideMethodDescription.js +0 -35
- package/doc/src/components/Esdoc/Properties.js +0 -89
- package/doc/src/components/Esdoc/README.md +0 -45
- package/doc/src/components/Esdoc/SignatureHTML.js +0 -123
- package/doc/src/components/Esdoc/SingleDoc.js +0 -31
- package/doc/src/components/Esdoc/SummaryDoc.js +0 -160
- package/doc/src/components/Esdoc/SummaryHTML.js +0 -96
- package/doc/src/components/Esdoc/TypeDocLinkHTML.js +0 -251
- package/doc/src/components/Esdoc/index.js +0 -7
- package/doc/src/components/Esdoc/taffydb.js +0 -2070
- package/doc/src/components/Example.js +0 -200
- package/doc/src/components/ExampleCard.js +0 -126
- package/doc/src/components/Examples.js +0 -78
- package/doc/src/components/Home.js +0 -121
- package/doc/src/components/TrackerExample.js +0 -39
- package/doc/src/examples.js +0 -117
- package/doc/styles/App.scss +0 -53
- package/doc/styles/identifiers.css +0 -38
- package/doc/styles/search.css +0 -76
- package/doc/styles/style.css +0 -603
- package/esdoc/README.md +0 -27
- package/esdoc/plugins/MyPlugin.js +0 -69
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
- package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
- package/esdoc/plugins/externals-plugin/externals.js +0 -93
- package/esdoc/plugins/optional-chaining-plugin/Plugin.js +0 -8
- package/global-setup.js +0 -3
- package/jest.config.js +0 -24
- package/pull_request_template.md +0 -17
- package/scripts/read-pkg-json.js +0 -22
- package/src/api/RealtimeAPI.test.js +0 -144
- package/src/api/RealtimeAPI.ts +0 -712
- package/src/api/RoutingAPI.test.js +0 -41
- package/src/api/RoutingAPI.ts +0 -47
- package/src/api/StopsAPI.test.js +0 -34
- package/src/api/StopsAPI.ts +0 -45
- package/src/common/api/HttpAPI.test.js +0 -68
- package/src/common/api/HttpAPI.ts +0 -77
- package/src/common/api/WebSocketAPI.test.js +0 -421
- package/src/common/api/WebSocketAPI.ts +0 -515
- package/src/common/controls/ControlCommon.test.js +0 -106
- package/src/common/controls/ControlCommon.ts +0 -194
- package/src/common/controls/CopyrightControlCommon.ts +0 -41
- package/src/common/controls/StopFinderControlCommon.ts +0 -192
- package/src/common/layers/LayerCommon.test.js +0 -158
- package/src/common/layers/LayerCommon.ts +0 -321
- package/src/common/mixins/RealtimeLayerMixin.ts +0 -1168
- package/src/common/mixins/UserInteractionsLayerMixin.test.js +0 -227
- package/src/common/mixins/UserInteractionsLayerMixin.ts +0 -352
- package/src/common/styles/realtimeDefaultStyle.ts +0 -436
- package/src/common/styles/realtimeDelayStyle.ts +0 -27
- package/src/common/styles/realtimeHeadingStyle.ts +0 -138
- package/src/common/styles/realtimeSimpleStyle.ts +0 -25
- package/src/common/utils/compareDepartures.ts +0 -46
- package/src/common/utils/createCanvas.ts +0 -33
- package/src/common/utils/createRealtimeFilters.test.js +0 -100
- package/src/common/utils/createRealtimeFilters.ts +0 -96
- package/src/common/utils/debounceDeparturesMessages.ts +0 -52
- package/src/common/utils/debounceWebsocketMessages.ts +0 -47
- package/src/common/utils/getLayersAsFlatArray.ts +0 -17
- package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/src/common/utils/getMapboxMapCopyrights.ts +0 -52
- package/src/common/utils/getMapboxRender.ts +0 -104
- package/src/common/utils/getMaplibreRender.ts +0 -54
- package/src/common/utils/getUrlWithParams.ts +0 -21
- package/src/common/utils/getVehiclePosition.ts +0 -92
- package/src/common/utils/realtimeConfig.test.js +0 -57
- package/src/common/utils/realtimeConfig.ts +0 -228
- package/src/common/utils/removeDuplicate.test.js +0 -22
- package/src/common/utils/removeDuplicate.ts +0 -22
- package/src/common/utils/renderTrajectories.ts +0 -194
- package/src/common/utils/sortAndFilterDepartures.ts +0 -78
- package/src/common/utils/sortByDelay.ts +0 -29
- package/src/common/utils/timeUtils.test.js +0 -16
- package/src/common/utils/timeUtils.ts +0 -45
- package/src/index.js +0 -10
- package/src/mapbox/layers/Layer.test.js +0 -217
- package/src/mapbox/layers/Layer.ts +0 -144
- package/src/mapbox/layers/RealtimeLayer.test.js +0 -13
- package/src/mapbox/layers/RealtimeLayer.ts +0 -350
- package/src/mapbox/utils/getMercatorResolution.ts +0 -21
- package/src/mapbox/utils/getSourceCoordinates.ts +0 -34
- package/src/ol/README.md +0 -0
- package/src/ol/controls/CopyrightControl.test.js +0 -211
- package/src/ol/controls/CopyrightControl.ts +0 -82
- package/src/ol/controls/RoutingControl.test.js +0 -205
- package/src/ol/controls/RoutingControl.ts +0 -869
- package/src/ol/controls/StopFinderControl.test.js +0 -59
- package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/src/ol/layers/Layer.test.js +0 -212
- package/src/ol/layers/Layer.ts +0 -252
- package/src/ol/layers/MapGlLayer.ts +0 -294
- package/src/ol/layers/MapboxLayer.test.js +0 -190
- package/src/ol/layers/MapboxLayer.ts +0 -136
- package/src/ol/layers/MapboxStyleLayer.test.js +0 -258
- package/src/ol/layers/MapboxStyleLayer.ts +0 -466
- package/src/ol/layers/RealtimeLayer.test.js +0 -84
- package/src/ol/layers/RealtimeLayer.ts +0 -465
- package/src/ol/layers/RoutingLayer.test.js +0 -48
- package/src/ol/layers/RoutingLayer.ts +0 -113
- package/src/ol/layers/VectorLayer.test.js +0 -87
- package/src/ol/layers/VectorLayer.ts +0 -48
- package/src/ol/layers/WMSLayer.test.js +0 -65
- package/src/ol/layers/WMSLayer.ts +0 -114
- package/src/ol/styles/fullTrajectoryDelayStyle.ts +0 -37
- package/src/ol/styles/fullTrajectoryStyle.ts +0 -56
- package/tsconfig.json +0 -23
- /package/{src/api → api}/index.js +0 -0
- /package/{src/common → common}/index.js +0 -0
- /package/{src/common → common}/styles/index.js +0 -0
- /package/{src/mapbox → mapbox}/controls/index.js +0 -0
- /package/{src/mapbox → mapbox}/index.js +0 -0
- /package/{src/mapbox → mapbox}/layers/index.js +0 -0
- /package/{src/mapbox → mapbox}/utils/index.js +0 -0
- /package/{src/ol → ol}/controls/index.js +0 -0
- /package/{src/ol → ol}/index.js +0 -0
- /package/{src/ol → ol}/layers/index.js +0 -0
- /package/{src/ol → ol}/styles/index.js +0 -0
- /package/{src/types → types}/common.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/realtime.d.ts +0 -0
- /package/{src/types → types}/routing.d.ts +0 -0
- /package/{src/types → types}/stops.d.ts +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Feature, Point } from 'geojson';
|
|
2
1
|
import { fromLonLat } from 'ol/proj';
|
|
3
2
|
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Search stations.
|
|
7
5
|
*
|
|
@@ -23,13 +21,12 @@ import StopFinderControlCommon from '../../common/controls/StopFinderControlComm
|
|
|
23
21
|
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
24
22
|
*/
|
|
25
23
|
class StopFinderControl extends StopFinderControlCommon {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
onSuggestionClick(suggestion) {
|
|
28
|
+
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
29
|
+
this.map.getView().setCenter(coord);
|
|
30
|
+
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
export default StopFinderControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/index.js"],"names":[],"mappings":""}
|
package/ol/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ol/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Map } from 'ol';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import LayerGroup from 'ol/layer/Group';
|
|
4
|
+
import OlLayer from 'ol/layer/Layer';
|
|
5
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
6
|
+
import type { LayerCommonOptions } from '../../common/layers/LayerCommon';
|
|
7
|
+
import type { UserInteractionCallback } from '../../types';
|
|
8
|
+
export type OlLayerOptions = LayerCommonOptions & {
|
|
9
|
+
olLayer?: OlLayer;
|
|
10
|
+
};
|
|
11
|
+
declare const Layer_base: typeof LayerCommon;
|
|
12
|
+
/**
|
|
13
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
17
|
+
*
|
|
18
|
+
* const layer = new Layer({
|
|
19
|
+
* olLayer: ...,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
23
|
+
*
|
|
24
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
25
|
+
* @extends {LayerCommon}
|
|
26
|
+
*/
|
|
27
|
+
declare class Layer extends Layer_base {
|
|
28
|
+
olLayer?: OlLayer | LayerGroup;
|
|
29
|
+
olListenersKeys: EventsKey[];
|
|
30
|
+
options: OlLayerOptions;
|
|
31
|
+
visible: boolean;
|
|
32
|
+
copyrights: string[];
|
|
33
|
+
map?: Map;
|
|
34
|
+
singleClickListenerKey: EventsKey;
|
|
35
|
+
pointerMoveListenerKey: EventsKey;
|
|
36
|
+
userInteractions?: boolean;
|
|
37
|
+
userClickInteractions?: boolean;
|
|
38
|
+
userHoverInteractions?: boolean;
|
|
39
|
+
userClickCallbacks?: UserInteractionCallback[];
|
|
40
|
+
userHoverCallbacks?: UserInteractionCallback[];
|
|
41
|
+
onUserClickCallback: () => void;
|
|
42
|
+
onUserMoveCallback: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Constructor.
|
|
45
|
+
*
|
|
46
|
+
* @param {LayerCommonOptions} options
|
|
47
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
48
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
49
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
50
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
51
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
52
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
53
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
54
|
+
*/
|
|
55
|
+
constructor(options: OlLayerOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Define layer's properties.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
defineProperties(options: OlLayerOptions): void;
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the layer and listen to feature clicks.
|
|
64
|
+
* @param {ol/Map~Map} map
|
|
65
|
+
*/
|
|
66
|
+
attachToMap(map: Map): void;
|
|
67
|
+
/**
|
|
68
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
69
|
+
*/
|
|
70
|
+
detachFromMap(): void;
|
|
71
|
+
activateUserInteractions(): void;
|
|
72
|
+
deactivateUserInteractions(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
toggleVisibleListeners(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Create a copy of the Layer.
|
|
80
|
+
* @param {Object} newOptions Options to override
|
|
81
|
+
* @return {Layer} A Layer
|
|
82
|
+
*/
|
|
83
|
+
clone(newOptions: OlLayerOptions): Layer;
|
|
84
|
+
}
|
|
85
|
+
export default Layer;
|
|
86
|
+
//# sourceMappingURL=Layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAEF;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE/B,eAAe,EAAG,SAAS,EAAE,CAAC;IAI9B,OAAO,EAAG,cAAc,CAAC;IAEzB,OAAO,EAAG,OAAO,CAAC;IAElB,UAAU,EAAG,MAAM,EAAE,CAAC;IAEtB,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,sBAAsB,EAAG,SAAS,CAAC;IAEnC,sBAAsB,EAAG,SAAS,CAAC;IAInC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;;;;;;;;;OAWG;gBACS,OAAO,EAAE,cAAc;IAMnC;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,cAAc;IAUxC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG;IAiFpB;;OAEG;IACH,aAAa;IAcb,wBAAwB;IA2BxB,0BAA0B;IAI1B;;;OAGG;IACH,sBAAsB;IAQtB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,cAAc;CAGjC;AACD,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { unByKey } from 'ol/Observable';
|
|
2
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
3
|
+
import userInteractionsMixin from '../../common/mixins/UserInteractionsLayerMixin';
|
|
4
|
+
/**
|
|
5
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
9
|
+
*
|
|
10
|
+
* const layer = new Layer({
|
|
11
|
+
* olLayer: ...,
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
15
|
+
*
|
|
16
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
17
|
+
* @extends {LayerCommon}
|
|
18
|
+
*/
|
|
19
|
+
class Layer extends userInteractionsMixin(LayerCommon) {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor.
|
|
22
|
+
*
|
|
23
|
+
* @param {LayerCommonOptions} options
|
|
24
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
25
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
26
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
27
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
28
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
29
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
30
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options) {
|
|
33
|
+
var _a;
|
|
34
|
+
super(options);
|
|
35
|
+
(_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.setVisible(this.visible);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Define layer's properties.
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
defineProperties(options) {
|
|
43
|
+
super.defineProperties(options);
|
|
44
|
+
Object.defineProperties(this, {
|
|
45
|
+
olLayer: { value: options.olLayer, writable: true },
|
|
46
|
+
olListenersKeys: {
|
|
47
|
+
value: [],
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Initialize the layer and listen to feature clicks.
|
|
53
|
+
* @param {ol/Map~Map} map
|
|
54
|
+
*/
|
|
55
|
+
attachToMap(map) {
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
57
|
+
super.attachToMap(map);
|
|
58
|
+
if (!this.map) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Make sure the visiblity is correct
|
|
62
|
+
(_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.setVisible(this.visible);
|
|
63
|
+
if (this.olLayer &&
|
|
64
|
+
!((_d = (_c = (_b = this.map) === null || _b === void 0 ? void 0 : _b.getLayers()) === null || _c === void 0 ? void 0 : _c.getArray()) === null || _d === void 0 ? void 0 : _d.includes(this.olLayer))) {
|
|
65
|
+
this.map.addLayer(this.olLayer);
|
|
66
|
+
}
|
|
67
|
+
this.olListenersKeys.push(
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
this.on('change:visible', () => {
|
|
70
|
+
if (this.olLayer) {
|
|
71
|
+
this.olLayer.setVisible(this.visible);
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
this.olListenersKeys.push(
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
this.on('change:minZoom', () => {
|
|
77
|
+
if (this.olLayer && this.get('minZoom')) {
|
|
78
|
+
this.olLayer.setMinZoom(this.get('minZoom'));
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
this.olListenersKeys.push(
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
this.on('change:maxZoom', () => {
|
|
84
|
+
if (this.olLayer && this.get('maxZoom')) {
|
|
85
|
+
this.olLayer.setMaxZoom(this.get('maxZoom'));
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
this.olListenersKeys.push(this.map.getLayers().on('remove', (evt) => {
|
|
89
|
+
if (evt.element === this.olLayer) {
|
|
90
|
+
this.detachFromMap();
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
this.toggleVisibleListeners();
|
|
94
|
+
this.olListenersKeys.push(
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
this.on('change:visible', this.toggleVisibleListeners));
|
|
97
|
+
// We set the copyright to the source used by the layer.
|
|
98
|
+
if (this.copyrights && this.olLayer) {
|
|
99
|
+
const attributions = this.copyrights || [];
|
|
100
|
+
if (this.olLayer.getLayers) {
|
|
101
|
+
this.olLayer
|
|
102
|
+
.getLayers()
|
|
103
|
+
.getArray()
|
|
104
|
+
.forEach((layer) => {
|
|
105
|
+
var _a;
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
if (layer.getSource) {
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.setAttributions(attributions);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
}
|
|
114
|
+
else if (this.olLayer.getSource) {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
(_e = this.olLayer.getSource()) === null || _e === void 0 ? void 0 : _e.setAttributions(attributions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
122
|
+
*/
|
|
123
|
+
detachFromMap() {
|
|
124
|
+
var _a, _b, _c;
|
|
125
|
+
this.deactivateUserInteractions();
|
|
126
|
+
unByKey(this.olListenersKeys);
|
|
127
|
+
if (this.olLayer &&
|
|
128
|
+
((_c = (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getLayers()) === null || _b === void 0 ? void 0 : _b.getArray()) === null || _c === void 0 ? void 0 : _c.includes(this.olLayer))) {
|
|
129
|
+
this.map.removeLayer(this.olLayer);
|
|
130
|
+
}
|
|
131
|
+
super.detachFromMap();
|
|
132
|
+
}
|
|
133
|
+
activateUserInteractions() {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
this.deactivateUserInteractions();
|
|
136
|
+
if (this.map &&
|
|
137
|
+
this.userInteractions &&
|
|
138
|
+
this.userClickInteractions &&
|
|
139
|
+
((_a = this.userClickCallbacks) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
140
|
+
this.singleClickListenerKey = this.map.on('singleclick', this.onUserClickCallback);
|
|
141
|
+
this.olListenersKeys.push(this.singleClickListenerKey);
|
|
142
|
+
}
|
|
143
|
+
if (this.map &&
|
|
144
|
+
this.userInteractions &&
|
|
145
|
+
this.userHoverInteractions &&
|
|
146
|
+
((_b = this.userHoverCallbacks) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
147
|
+
this.pointerMoveListenerKey = this.map.on('pointermove', this.onUserMoveCallback);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
deactivateUserInteractions() {
|
|
151
|
+
unByKey([this.pointerMoveListenerKey, this.singleClickListenerKey]);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
toggleVisibleListeners() {
|
|
158
|
+
if (this.visible) {
|
|
159
|
+
this.activateUserInteractions();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.deactivateUserInteractions();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a copy of the Layer.
|
|
167
|
+
* @param {Object} newOptions Options to override
|
|
168
|
+
* @return {Layer} A Layer
|
|
169
|
+
*/
|
|
170
|
+
clone(newOptions) {
|
|
171
|
+
return new Layer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export default Layer;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="mapbox-gl" />
|
|
2
|
+
import { RenderFunction } from 'ol/layer/Layer';
|
|
3
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
4
|
+
import OlMap from 'ol/Map';
|
|
5
|
+
import { Coordinate } from 'ol/coordinate';
|
|
6
|
+
import { AnyMapboxMap, AnyMapboxMapClass, LayerGetFeatureInfoResponse } from '../../types';
|
|
7
|
+
import Layer, { OlLayerOptions } from './Layer';
|
|
8
|
+
export type MapGlLayerOptions = OlLayerOptions & {
|
|
9
|
+
url?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
apiKeyName?: string;
|
|
12
|
+
mapOptions?: any;
|
|
13
|
+
tabIndex?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Common class for Mapbox and Maplibre and potential other fork from Mapbox.
|
|
17
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs.
|
|
18
|
+
*/
|
|
19
|
+
declare class MapGlLayer extends Layer {
|
|
20
|
+
mbMap?: AnyMapboxMap;
|
|
21
|
+
styleUrl?: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
apiKeyName: string;
|
|
24
|
+
format: GeoJSON;
|
|
25
|
+
loaded: boolean;
|
|
26
|
+
options: MapGlLayerOptions;
|
|
27
|
+
constructor(options: MapGlLayerOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the layer and listen to feature clicks.
|
|
30
|
+
* @param {ol/Map~Map} map
|
|
31
|
+
*/
|
|
32
|
+
attachToMap(map: OlMap): void;
|
|
33
|
+
/**
|
|
34
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
35
|
+
*/
|
|
36
|
+
detachFromMap(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Create the mapbox map.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
loadMbMap(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Update attributions of the source.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
updateAttribution(evt: maplibregl.MapLibreEvent | mapboxgl.MapboxEvent): void;
|
|
47
|
+
/**
|
|
48
|
+
* Request feature information for a given coordinate.
|
|
49
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
50
|
+
* @param {Object} options A [mapboxgl.Map#queryrenderedfeatures](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures) options parameter.
|
|
51
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate. The original Mapbox feature is available as a property named 'mapboxFeature'.
|
|
52
|
+
*/
|
|
53
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate, options: any): Promise<LayerGetFeatureInfoResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Return the render function function for the ol layer.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
getOlLayerRender(): RenderFunction;
|
|
59
|
+
/**
|
|
60
|
+
* Return the Class to instanciate for the mapbox map.
|
|
61
|
+
*
|
|
62
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
63
|
+
*/
|
|
64
|
+
getMapboxMapClass(): AnyMapboxMapClass;
|
|
65
|
+
}
|
|
66
|
+
export default MapGlLayer;
|
|
67
|
+
//# sourceMappingURL=MapGlLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapGlLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapGlLayer.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,UAAW,SAAQ,KAAK;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAG,MAAM,CAAC;IAEpB,MAAM,EAAG,OAAO,CAAC;IAEjB,MAAM,EAAG,OAAO,CAAC;IAEjB,OAAO,EAAG,iBAAiB,CAAC;gBAEhB,OAAO,EAAE,iBAAiB;IAmCtC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAkBtB;;OAEG;IACH,aAAa;IAab;;;OAGG;IACH,SAAS;IAuET;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW;IAStE;;;;;OAKG;IACH,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,2BAA2B,CAAC;IAqDvC;;;OAGG;IAEH,gBAAgB,IAAI,cAAc;IAOlC;;;;OAIG;IAEH,iBAAiB,IAAI,iBAAiB;CAMvC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { toLonLat } from 'ol/proj';
|
|
3
|
+
import OlLayer from 'ol/layer/Layer';
|
|
4
|
+
import Source from 'ol/source/Source';
|
|
5
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
6
|
+
import BaseEvent from 'ol/events/Event';
|
|
7
|
+
import { getUrlWithParams, getMapboxMapCopyrights } from '../../common/utils';
|
|
8
|
+
import Layer from './Layer';
|
|
9
|
+
/**
|
|
10
|
+
* Common class for Mapbox and Maplibre and potential other fork from Mapbox.
|
|
11
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs.
|
|
12
|
+
*/
|
|
13
|
+
class MapGlLayer extends Layer {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options);
|
|
16
|
+
this.olLayer = new OlLayer({
|
|
17
|
+
source: new Source({}),
|
|
18
|
+
render: this.getOlLayerRender(),
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Url of the mapbox style.
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
this.styleUrl = options.url;
|
|
26
|
+
/**
|
|
27
|
+
* Api key for the url of the mapbox style.
|
|
28
|
+
* If set to false, the apiKey is not required.
|
|
29
|
+
* @type {string}
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
this.apiKey = options.apiKey;
|
|
33
|
+
/**
|
|
34
|
+
* Name of the apiKey to set in the url request.
|
|
35
|
+
* Default is 'key'.
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
this.apiKeyName = options.apiKeyName || 'key';
|
|
40
|
+
/** @private */
|
|
41
|
+
this.updateAttribution = this.updateAttribution.bind(this);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initialize the layer and listen to feature clicks.
|
|
45
|
+
* @param {ol/Map~Map} map
|
|
46
|
+
*/
|
|
47
|
+
attachToMap(map) {
|
|
48
|
+
super.attachToMap(map);
|
|
49
|
+
if (!this.map) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The feature format.
|
|
54
|
+
* @type {ol/format/GeoJSON}
|
|
55
|
+
*/
|
|
56
|
+
this.format = new GeoJSON({
|
|
57
|
+
featureProjection: this.map.getView().getProjection(),
|
|
58
|
+
});
|
|
59
|
+
this.loadMbMap();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
63
|
+
*/
|
|
64
|
+
detachFromMap() {
|
|
65
|
+
if (this.mbMap) {
|
|
66
|
+
this.mbMap.off('idle', this.updateAttribution);
|
|
67
|
+
// Some asynchrone repaints are triggered even if the mbMap has been removed,
|
|
68
|
+
// to avoid display of errors we set an empty function.
|
|
69
|
+
this.mbMap.triggerRepaint = () => { };
|
|
70
|
+
this.mbMap.remove();
|
|
71
|
+
this.mbMap = undefined;
|
|
72
|
+
}
|
|
73
|
+
this.loaded = false;
|
|
74
|
+
super.detachFromMap();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create the mapbox map.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
loadMbMap() {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
this.olListenersKeys.push(
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('change:target', () => {
|
|
85
|
+
this.loadMbMap();
|
|
86
|
+
}));
|
|
87
|
+
if (!((_b = this.map) === null || _b === void 0 ? void 0 : _b.getTargetElement())) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!this.visible) {
|
|
91
|
+
// On next change of visibility we load the map
|
|
92
|
+
this.olListenersKeys.push(
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
this.once('change:visible', () => {
|
|
95
|
+
this.loadMbMap();
|
|
96
|
+
}));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const container = document.createElement('div');
|
|
100
|
+
container.style.position = 'absolute';
|
|
101
|
+
container.style.width = '100%';
|
|
102
|
+
container.style.height = '100%';
|
|
103
|
+
if (!this.styleUrl) {
|
|
104
|
+
// eslint-disable-next-line no-console
|
|
105
|
+
console.error(`No styleUrl defined for mapbox layer: ${this.styleUrl}`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!this.apiKey && !((_c = this.styleUrl) === null || _c === void 0 ? void 0 : _c.includes(this.apiKeyName))) {
|
|
109
|
+
// eslint-disable-next-line no-console
|
|
110
|
+
console.error(`No apiKey defined for mapbox layer with style url to ${this.styleUrl}`);
|
|
111
|
+
}
|
|
112
|
+
const Map = this.getMapboxMapClass();
|
|
113
|
+
/**
|
|
114
|
+
* A mapbox map
|
|
115
|
+
* @type {mapboxgl.Map}
|
|
116
|
+
*/
|
|
117
|
+
this.mbMap = new Map(Object.assign({ style: getUrlWithParams(this.styleUrl, {
|
|
118
|
+
[this.apiKeyName]: this.apiKey,
|
|
119
|
+
}).toString(), container, interactive: false, trackResize: false, attributionControl: false }, (this.options.mapOptions || {})));
|
|
120
|
+
this.mbMap.once('load', () => {
|
|
121
|
+
/**
|
|
122
|
+
* Is the map loaded.
|
|
123
|
+
* @type {boolean}
|
|
124
|
+
*/
|
|
125
|
+
this.loaded = true;
|
|
126
|
+
this.dispatchEvent(new BaseEvent('load'));
|
|
127
|
+
});
|
|
128
|
+
this.mbMap.on('idle', this.updateAttribution);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Update attributions of the source.
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
updateAttribution(evt) {
|
|
135
|
+
var _a, _b, _c;
|
|
136
|
+
const newAttributions = getMapboxMapCopyrights(evt.target) || [];
|
|
137
|
+
if (((_a = this.copyrights) === null || _a === void 0 ? void 0 : _a.toString()) !== newAttributions.toString()) {
|
|
138
|
+
this.copyrights = newAttributions;
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
(_c = (_b = this.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setAttributions(newAttributions);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Request feature information for a given coordinate.
|
|
145
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
146
|
+
* @param {Object} options A [mapboxgl.Map#queryrenderedfeatures](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures) options parameter.
|
|
147
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate. The original Mapbox feature is available as a property named 'mapboxFeature'.
|
|
148
|
+
*/
|
|
149
|
+
getFeatureInfoAtCoordinate(coordinate, options) {
|
|
150
|
+
// Ignore the getFeatureInfo until the mapbox map is loaded
|
|
151
|
+
if (!options ||
|
|
152
|
+
!this.format ||
|
|
153
|
+
!this.mbMap ||
|
|
154
|
+
!this.mbMap.isStyleLoaded()) {
|
|
155
|
+
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
156
|
+
}
|
|
157
|
+
const pixel = coordinate &&
|
|
158
|
+
this.mbMap.project(toLonLat(coordinate));
|
|
159
|
+
let pixels;
|
|
160
|
+
if (this.hitTolerance) {
|
|
161
|
+
const { x, y } = pixel;
|
|
162
|
+
pixels = [
|
|
163
|
+
{
|
|
164
|
+
x: x - this.hitTolerance,
|
|
165
|
+
y: y - this.hitTolerance,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
x: x + this.hitTolerance,
|
|
169
|
+
y: y + this.hitTolerance,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
// At this point we get GeoJSON Mapbox feature, we transform it to an OpenLayers
|
|
174
|
+
// feature to be consistent with other layers.
|
|
175
|
+
const features = this.mbMap
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
.queryRenderedFeatures(pixels || pixel, options)
|
|
178
|
+
.map((feature) => {
|
|
179
|
+
const olFeature = this.format.readFeature(feature);
|
|
180
|
+
if (olFeature) {
|
|
181
|
+
// We save the original mapbox feature to avoid losing informations
|
|
182
|
+
// potentially needed for other functionnality like highlighting
|
|
183
|
+
// (id, layer id, source, sourceLayer ...)
|
|
184
|
+
olFeature.set('mapboxFeature', feature);
|
|
185
|
+
}
|
|
186
|
+
return olFeature;
|
|
187
|
+
});
|
|
188
|
+
return Promise.resolve({
|
|
189
|
+
layer: this,
|
|
190
|
+
features,
|
|
191
|
+
coordinate,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Return the render function function for the ol layer.
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
// eslint-disable-next-line class-methods-use-this
|
|
199
|
+
getOlLayerRender() {
|
|
200
|
+
// eslint-disable-next-line no-console
|
|
201
|
+
console.error('This function must be implemented in subclasses');
|
|
202
|
+
const div = document.createElement('div');
|
|
203
|
+
return () => div;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Return the Class to instanciate for the mapbox map.
|
|
207
|
+
*
|
|
208
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
209
|
+
*/
|
|
210
|
+
// eslint-disable-next-line class-methods-use-this
|
|
211
|
+
getMapboxMapClass() {
|
|
212
|
+
// eslint-disable-next-line no-console
|
|
213
|
+
console.error('This function must be implemented in subclasses');
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export default MapGlLayer;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Map } from 'mapbox-gl';
|
|
2
|
+
import { Coordinate } from 'ol/coordinate';
|
|
3
|
+
import type OlMap from 'ol/Map';
|
|
4
|
+
import { Size } from 'ol/size';
|
|
5
|
+
import MapGlLayer, { MapGlLayerOptions } from './MapGlLayer';
|
|
6
|
+
/**
|
|
7
|
+
* A class representing Mapboxlayer to display on BasicMap
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { MapboxLayer } from 'mobility-toolbox-js/ol';
|
|
11
|
+
*
|
|
12
|
+
* const layer = new MapboxLayer({
|
|
13
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json',
|
|
14
|
+
* apikey: 'yourApiKey',
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
18
|
+
* @extends {Layer}
|
|
19
|
+
*/
|
|
20
|
+
export default class MapboxLayer extends MapGlLayer {
|
|
21
|
+
renderState?: {
|
|
22
|
+
center?: Coordinate;
|
|
23
|
+
zoom?: number;
|
|
24
|
+
visible?: boolean;
|
|
25
|
+
opacity?: number;
|
|
26
|
+
resolution?: number;
|
|
27
|
+
rotation?: number;
|
|
28
|
+
size?: Size;
|
|
29
|
+
};
|
|
30
|
+
tabIndex?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the layer and listen to feature clicks.
|
|
33
|
+
* @param {ol/Map~Map} map
|
|
34
|
+
*/
|
|
35
|
+
attachToMap(map: OlMap): void;
|
|
36
|
+
/**
|
|
37
|
+
* Create the mapbox map.
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
loadMbMap(): void;
|
|
41
|
+
getOlLayerRender(): import("ol/layer/Layer").RenderFunction;
|
|
42
|
+
getMapboxMapClass(): typeof Map;
|
|
43
|
+
/**
|
|
44
|
+
* Create a copy of the MapboxLayer.
|
|
45
|
+
* @param {Object} newOptions Options to override
|
|
46
|
+
* @return {MapboxLayer} A MapboxLayer
|
|
47
|
+
*/
|
|
48
|
+
clone(newOptions: MapGlLayerOptions): MapboxLayer;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=MapboxLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapboxLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapboxLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,WAAW,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,IAAI,CAAC;KACb,CAAC;IAEF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAsBtB;;;OAGG;IACH,SAAS;IAqDT,gBAAgB;IAKhB,iBAAiB;IAIjB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,iBAAiB;CAGpC"}
|