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/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ol/index.js"],"names":[],"mappings":""}
|
package/ol/layers/Layer.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
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
|
package/ol/layers/Layer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/ol/layers/Layer.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
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;
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/ol/layers/MapGlLayer.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
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;
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|