mobility-toolbox-js 3.0.0-beta.16 → 3.0.0-beta.17
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/mbt.js +53 -50
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/layers/MaplibreLayer.d.ts +10 -0
- package/ol/layers/MaplibreLayer.js +2 -2
- package/ol/layers/MaplibreStyleLayer.js +52 -51
- package/package.json +1 -1
package/mbt.js
CHANGED
|
@@ -44671,11 +44671,13 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
44671
44671
|
};
|
|
44672
44672
|
var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(MapLibreLayer) {
|
|
44673
44673
|
get mbMap() {
|
|
44674
|
-
console.warn(".mbMap deprecated. Use layer.maplibreMap.");
|
|
44674
|
+
console.warn("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap.");
|
|
44675
44675
|
return this.maplibreMap;
|
|
44676
44676
|
}
|
|
44677
44677
|
get maplibreMap() {
|
|
44678
|
-
console.warn(
|
|
44678
|
+
console.warn(
|
|
44679
|
+
"MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."
|
|
44680
|
+
);
|
|
44679
44681
|
return this.mapLibreMap;
|
|
44680
44682
|
}
|
|
44681
44683
|
// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
|
|
@@ -44982,12 +44984,12 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
44982
44984
|
);
|
|
44983
44985
|
return;
|
|
44984
44986
|
}
|
|
44985
|
-
const {
|
|
44986
|
-
if (
|
|
44987
|
-
if (
|
|
44987
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
44988
|
+
if (mapLibreMap) {
|
|
44989
|
+
if (mapLibreMap.loaded()) {
|
|
44988
44990
|
this.onLoad();
|
|
44989
44991
|
} else {
|
|
44990
|
-
|
|
44992
|
+
mapLibreMap.once("load", this.onLoad);
|
|
44991
44993
|
}
|
|
44992
44994
|
}
|
|
44993
44995
|
this.olEventsKeys.push(
|
|
@@ -45009,8 +45011,8 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45009
45011
|
* @override
|
|
45010
45012
|
*/
|
|
45011
45013
|
detachFromMap() {
|
|
45012
|
-
if (this.maplibreLayer?.
|
|
45013
|
-
this.maplibreLayer.
|
|
45014
|
+
if (this.maplibreLayer?.mapLibreMap) {
|
|
45015
|
+
this.maplibreLayer.mapLibreMap.off("load", this.onLoad);
|
|
45014
45016
|
this.removeLayers();
|
|
45015
45017
|
this.removeSources();
|
|
45016
45018
|
}
|
|
@@ -45018,43 +45020,43 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45018
45020
|
}
|
|
45019
45021
|
/** @private */
|
|
45020
45022
|
addSources() {
|
|
45021
|
-
if (!this.maplibreLayer?.
|
|
45023
|
+
if (!this.maplibreLayer?.mapLibreMap || !this.sources) {
|
|
45022
45024
|
return;
|
|
45023
45025
|
}
|
|
45024
|
-
const {
|
|
45025
|
-
if (
|
|
45026
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45027
|
+
if (mapLibreMap) {
|
|
45026
45028
|
Object.entries(this.sources).forEach(([id, source]) => {
|
|
45027
|
-
if (!
|
|
45028
|
-
|
|
45029
|
+
if (!mapLibreMap.getSource(id)) {
|
|
45030
|
+
mapLibreMap.addSource(id, source);
|
|
45029
45031
|
}
|
|
45030
45032
|
});
|
|
45031
45033
|
}
|
|
45032
45034
|
}
|
|
45033
45035
|
/** @private */
|
|
45034
45036
|
removeSources() {
|
|
45035
|
-
if (!this.maplibreLayer?.
|
|
45037
|
+
if (!this.maplibreLayer?.mapLibreMap || !this.sources) {
|
|
45036
45038
|
return;
|
|
45037
45039
|
}
|
|
45038
|
-
const {
|
|
45039
|
-
if (
|
|
45040
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45041
|
+
if (mapLibreMap) {
|
|
45040
45042
|
Object.keys(this.sources).forEach((id) => {
|
|
45041
|
-
if (
|
|
45042
|
-
|
|
45043
|
+
if (mapLibreMap.getSource(id)) {
|
|
45044
|
+
mapLibreMap.removeSource(id);
|
|
45043
45045
|
}
|
|
45044
45046
|
});
|
|
45045
45047
|
}
|
|
45046
45048
|
}
|
|
45047
45049
|
/** @private */
|
|
45048
45050
|
addLayers() {
|
|
45049
|
-
if (!this.maplibreLayer?.
|
|
45051
|
+
if (!this.maplibreLayer?.mapLibreMap || !Array.isArray(this.layers)) {
|
|
45050
45052
|
return;
|
|
45051
45053
|
}
|
|
45052
|
-
const {
|
|
45053
|
-
if (
|
|
45054
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45055
|
+
if (mapLibreMap) {
|
|
45054
45056
|
this.layers.forEach((layer) => {
|
|
45055
45057
|
const { id, source } = layer;
|
|
45056
|
-
if ((!source || source &&
|
|
45057
|
-
|
|
45058
|
+
if ((!source || source && mapLibreMap.getSource(source)) && id && !mapLibreMap.getLayer(id)) {
|
|
45059
|
+
mapLibreMap.addLayer(layer, this.beforeId);
|
|
45058
45060
|
}
|
|
45059
45061
|
});
|
|
45060
45062
|
this.applyLayoutVisibility();
|
|
@@ -45062,15 +45064,15 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45062
45064
|
}
|
|
45063
45065
|
/** @private */
|
|
45064
45066
|
removeLayers() {
|
|
45065
|
-
if (!this.maplibreLayer?.
|
|
45067
|
+
if (!this.maplibreLayer?.mapLibreMap || !Array.isArray(this.layers)) {
|
|
45066
45068
|
return;
|
|
45067
45069
|
}
|
|
45068
|
-
const {
|
|
45069
|
-
if (
|
|
45070
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45071
|
+
if (mapLibreMap) {
|
|
45070
45072
|
this.layers.forEach((styleLayer) => {
|
|
45071
45073
|
const { id } = styleLayer;
|
|
45072
|
-
if (id &&
|
|
45073
|
-
|
|
45074
|
+
if (id && mapLibreMap.getLayer(id)) {
|
|
45075
|
+
mapLibreMap.removeLayer(id);
|
|
45074
45076
|
}
|
|
45075
45077
|
});
|
|
45076
45078
|
}
|
|
@@ -45080,17 +45082,18 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45080
45082
|
* @private
|
|
45081
45083
|
*/
|
|
45082
45084
|
onLoad() {
|
|
45083
|
-
if (!this.maplibreLayer?.
|
|
45085
|
+
if (!this.maplibreLayer?.mapLibreMap) {
|
|
45084
45086
|
return;
|
|
45085
45087
|
}
|
|
45086
45088
|
this.addSources();
|
|
45087
45089
|
this.addLayers();
|
|
45088
|
-
const {
|
|
45089
|
-
const style =
|
|
45090
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45091
|
+
const style = mapLibreMap.getStyle();
|
|
45090
45092
|
if (style?.layers && this.layersFilter) {
|
|
45091
45093
|
const styles = style.layers.filter(this.layersFilter);
|
|
45092
|
-
this.disabled
|
|
45094
|
+
this.set("disabled", !styles.length);
|
|
45093
45095
|
}
|
|
45096
|
+
this.applyLayoutVisibility();
|
|
45094
45097
|
}
|
|
45095
45098
|
/**
|
|
45096
45099
|
* Set the feature state of the features.
|
|
@@ -45099,10 +45102,10 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45099
45102
|
* @public
|
|
45100
45103
|
*/
|
|
45101
45104
|
setFeatureState(features, state) {
|
|
45102
|
-
if (!this.maplibreLayer?.
|
|
45105
|
+
if (!this.maplibreLayer?.mapLibreMap || !features.length) {
|
|
45103
45106
|
return;
|
|
45104
45107
|
}
|
|
45105
|
-
const {
|
|
45108
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45106
45109
|
features.forEach((feature2) => {
|
|
45107
45110
|
const { source, sourceLayer } = feature2.get(VECTOR_TILE_FEATURE_PROPERTY) || {};
|
|
45108
45111
|
if (!source && !sourceLayer || !feature2.getId()) {
|
|
@@ -45115,7 +45118,7 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45115
45118
|
}
|
|
45116
45119
|
return;
|
|
45117
45120
|
}
|
|
45118
|
-
|
|
45121
|
+
mapLibreMap.setFeatureState(
|
|
45119
45122
|
{
|
|
45120
45123
|
id: feature2.getId(),
|
|
45121
45124
|
source,
|
|
@@ -45134,19 +45137,19 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45134
45137
|
console.warn(
|
|
45135
45138
|
`Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead.`
|
|
45136
45139
|
);
|
|
45137
|
-
if (!this.maplibreLayer?.
|
|
45140
|
+
if (!this.maplibreLayer?.mapLibreMap) {
|
|
45138
45141
|
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
45139
45142
|
}
|
|
45140
|
-
const {
|
|
45141
|
-
if (!
|
|
45143
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45144
|
+
if (!mapLibreMap.isStyleLoaded()) {
|
|
45142
45145
|
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
45143
45146
|
}
|
|
45144
45147
|
let layers = this.layers || [];
|
|
45145
45148
|
if (this.layersFilter) {
|
|
45146
|
-
layers =
|
|
45149
|
+
layers = mapLibreMap.getStyle().layers.filter(this.layersFilter);
|
|
45147
45150
|
}
|
|
45148
45151
|
if (this.queryRenderedLayersFilter) {
|
|
45149
|
-
layers =
|
|
45152
|
+
layers = mapLibreMap.getStyle().layers.filter(this.queryRenderedLayersFilter);
|
|
45150
45153
|
}
|
|
45151
45154
|
return Promise.resolve({
|
|
45152
45155
|
features: [],
|
|
@@ -45159,14 +45162,14 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45159
45162
|
// * @param {maplibregl.filter} filter Determines which features should be rendered in a style layer.
|
|
45160
45163
|
// */
|
|
45161
45164
|
// setFilter(filter: { [key: string]: any }) {
|
|
45162
|
-
// if (!this.maplibreLayer?.
|
|
45165
|
+
// if (!this.maplibreLayer?.mapLibreMap) {
|
|
45163
45166
|
// return;
|
|
45164
45167
|
// }
|
|
45165
|
-
// const {
|
|
45168
|
+
// const { mapLibreMap } = this.maplibreLayer;
|
|
45166
45169
|
// this.styleLayers.forEach(({ id }) => {
|
|
45167
|
-
// if (id && filter &&
|
|
45170
|
+
// if (id && filter && mapLibreMap.getLayer(id)) {
|
|
45168
45171
|
// // @ts-ignore
|
|
45169
|
-
//
|
|
45172
|
+
// mapLibreMap.setFilter(id, filter);
|
|
45170
45173
|
// }
|
|
45171
45174
|
// });
|
|
45172
45175
|
// }
|
|
@@ -45216,21 +45219,21 @@ uniform ${i3} ${s3} u_${a3};
|
|
|
45216
45219
|
*/
|
|
45217
45220
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45218
45221
|
applyLayoutVisibility(evt) {
|
|
45219
|
-
if (!this.maplibreLayer?.
|
|
45222
|
+
if (!this.maplibreLayer?.mapLibreMap?.getStyle() || !this.layersFilter) {
|
|
45220
45223
|
return;
|
|
45221
45224
|
}
|
|
45222
|
-
const {
|
|
45223
|
-
const style =
|
|
45225
|
+
const { mapLibreMap } = this.maplibreLayer;
|
|
45226
|
+
const style = mapLibreMap.getStyle();
|
|
45224
45227
|
const visibilityValue = this.getVisible() ? "visible" : "none";
|
|
45225
45228
|
const layers = style.layers || [];
|
|
45226
45229
|
for (let i = 0; i < layers.length; i += 1) {
|
|
45227
45230
|
const layer = layers[i];
|
|
45228
45231
|
if (this.layersFilter(layer)) {
|
|
45229
45232
|
const { id } = layer;
|
|
45230
|
-
if (
|
|
45231
|
-
|
|
45233
|
+
if (mapLibreMap.getLayer(id)) {
|
|
45234
|
+
mapLibreMap.setLayoutProperty(id, "visibility", visibilityValue);
|
|
45232
45235
|
if (this.getMinZoom() || this.getMaxZoom()) {
|
|
45233
|
-
|
|
45236
|
+
mapLibreMap.setLayerZoomRange(
|
|
45234
45237
|
id,
|
|
45235
45238
|
this.getMinZoom() ? this.getMinZoom() - 1 : 0,
|
|
45236
45239
|
// Maplibre zoom = ol zoom - 1
|