mobility-toolbox-js 2.0.0-beta.47 → 2.0.0-beta.49
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/common/controls/ControlCommon.d.ts.map +1 -1
- package/common/controls/ControlCommon.js +3 -3
- package/common/controls/StopFinderControlCommon.d.ts +1 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -1
- package/common/controls/StopFinderControlCommon.js +3 -2
- package/common/utils/getMapboxRender.d.ts +2 -2
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +20 -11
- package/mapbox/index.d.ts +1 -0
- package/mapbox/index.js +1 -0
- package/mapbox/layers/Layer.d.ts +19 -7
- package/mapbox/layers/Layer.d.ts.map +1 -1
- package/mapbox/layers/Layer.js +8 -4
- package/mapbox/layers/RealtimeLayer.d.ts +112 -53
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
- package/mapbox/layers/RealtimeLayer.js +14 -8
- 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.js → utils/getSourceCoordinates.js} +6 -22
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mapbox/utils/index.js +2 -0
- package/mbt.js +116 -84
- package/mbt.js.map +3 -3
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts.map +1 -1
- package/ol/controls/CopyrightControl.js +0 -1
- package/ol/controls/RoutingControl.d.ts +1 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +1 -1
- package/ol/controls/StopFinderControl.d.ts.map +1 -1
- package/ol/layers/Layer.d.ts +4 -16
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.d.ts +11 -1
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +4 -4
- package/ol/layers/MapboxStyleLayer.d.ts +55 -78
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
- package/ol/layers/MapboxStyleLayer.js +63 -32
- package/ol/layers/VectorLayer.d.ts +6 -4
- package/ol/layers/VectorLayer.d.ts.map +1 -1
- package/ol/layers/WMSLayer.d.ts +15 -11
- package/ol/layers/WMSLayer.d.ts.map +1 -1
- package/ol/layers/WMSLayer.js +25 -9
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +2 -2
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -1
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/common.d.ts +1 -0
- package/mapbox/utils.d.ts +0 -8
- package/mapbox/utils.d.ts.map +0 -1
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import { getWidth, getHeight } from 'ol/extent';
|
|
2
|
-
import { fromLonLat } from 'ol/proj';
|
|
3
|
-
/**
|
|
4
|
-
* Get the current resolution of a Mapbox map.
|
|
5
|
-
* @param {mapboxgl.Map} map A map object.
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
export const getMercatorResolution = (map) => {
|
|
9
|
-
const bounds = map.getBounds().toArray();
|
|
10
|
-
const a = fromLonLat(bounds[0]);
|
|
11
|
-
const b = fromLonLat(bounds[1]);
|
|
12
|
-
const extent = [...a, ...b];
|
|
13
|
-
const { width, height } = map.getCanvas();
|
|
14
|
-
const xResolution = getWidth(extent) / width;
|
|
15
|
-
const yResolution = getHeight(extent) / height;
|
|
16
|
-
return Math.max(xResolution, yResolution);
|
|
17
|
-
};
|
|
18
1
|
/**
|
|
19
2
|
* Get the canvas source coordinates of the current map's extent.
|
|
20
3
|
* @param {mapboxgl.Map} map A map object.
|
|
21
4
|
* @private
|
|
22
5
|
*/
|
|
23
|
-
export const getSourceCoordinates = (map, pixelRatio) => {
|
|
6
|
+
export const getSourceCoordinates = (map, pixelRatio = 1) => {
|
|
24
7
|
// Requesting getBounds is not enough when we rotate the map, so we request manually each corner.
|
|
25
8
|
const { width, height } = map.getCanvas();
|
|
9
|
+
// @ts-ignore
|
|
26
10
|
const leftTop = map.unproject({ x: 0, y: 0 });
|
|
11
|
+
// @ts-ignore
|
|
27
12
|
const leftBottom = map.unproject({ x: 0, y: height / pixelRatio }); // southWest
|
|
13
|
+
// @ts-ignore
|
|
28
14
|
const rightBottom = map.unproject({
|
|
29
15
|
x: width / pixelRatio,
|
|
30
16
|
y: height / pixelRatio,
|
|
31
17
|
});
|
|
18
|
+
// @ts-ignore
|
|
32
19
|
const rightTop = map.unproject({ x: width / pixelRatio, y: 0 }); // north east
|
|
33
20
|
return [
|
|
34
21
|
[leftTop.lng, leftTop.lat],
|
|
@@ -37,7 +24,4 @@ export const getSourceCoordinates = (map, pixelRatio) => {
|
|
|
37
24
|
[leftBottom.lng, leftBottom.lat],
|
|
38
25
|
];
|
|
39
26
|
};
|
|
40
|
-
export default
|
|
41
|
-
getMercatorResolution,
|
|
42
|
-
getSourceCoordinates,
|
|
43
|
-
};
|
|
27
|
+
export default getSourceCoordinates;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mapbox/utils/index.js"],"names":[],"mappings":""}
|
package/mbt.js
CHANGED
|
@@ -35891,42 +35891,41 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
35891
35891
|
return (frameState) => {
|
|
35892
35892
|
const { map, mbMap, renderState, olLayer } = mapoxLayer;
|
|
35893
35893
|
if (!map || !mbMap) {
|
|
35894
|
-
return
|
|
35894
|
+
return document.createElement("div");
|
|
35895
35895
|
}
|
|
35896
35896
|
let changed = false;
|
|
35897
35897
|
const canvas2 = mbMap.getCanvas();
|
|
35898
35898
|
const { viewState } = frameState;
|
|
35899
|
-
const visible = olLayer
|
|
35900
|
-
if (renderState
|
|
35899
|
+
const visible = olLayer?.getVisible();
|
|
35900
|
+
if (renderState && renderState?.visible !== visible) {
|
|
35901
35901
|
canvas2.style.display = visible ? "block" : "none";
|
|
35902
35902
|
renderState.visible = visible;
|
|
35903
35903
|
canvas2.style.position = "absolute";
|
|
35904
35904
|
}
|
|
35905
|
-
const opacity = olLayer
|
|
35906
|
-
if (renderState.opacity !== opacity) {
|
|
35905
|
+
const opacity = olLayer?.getOpacity();
|
|
35906
|
+
if (canvas2 && renderState && renderState.opacity !== opacity) {
|
|
35907
35907
|
canvas2.style.opacity = opacity;
|
|
35908
35908
|
renderState.opacity = opacity;
|
|
35909
35909
|
}
|
|
35910
35910
|
const { rotation } = viewState;
|
|
35911
|
-
if (renderState.rotation !== rotation) {
|
|
35911
|
+
if (renderState && renderState.rotation !== rotation) {
|
|
35912
35912
|
mbMap.rotateTo(-(rotation || 0) * 180 / Math.PI, {
|
|
35913
35913
|
animate: false
|
|
35914
35914
|
});
|
|
35915
35915
|
changed = true;
|
|
35916
35916
|
renderState.rotation = rotation;
|
|
35917
35917
|
}
|
|
35918
|
-
if (renderState.zoom !== viewState.zoom || renderState.center[0] !== viewState.center[0] || renderState.center[1] !== viewState.center[1]) {
|
|
35918
|
+
if (renderState && renderState.center && (renderState.zoom !== viewState.zoom || renderState.center[0] !== viewState.center[0] || renderState.center[1] !== viewState.center[1])) {
|
|
35919
35919
|
mbMap.jumpTo({
|
|
35920
35920
|
center: toLonLat(viewState.center),
|
|
35921
|
-
zoom: viewState.zoom - 1
|
|
35922
|
-
animate: false
|
|
35921
|
+
zoom: viewState.zoom - 1
|
|
35923
35922
|
});
|
|
35924
35923
|
changed = true;
|
|
35925
35924
|
renderState.zoom = viewState.zoom;
|
|
35926
35925
|
renderState.center = viewState.center;
|
|
35927
35926
|
}
|
|
35928
35927
|
const size = map.getSize() || [0, 0];
|
|
35929
|
-
if (renderState.size[0] !== size[0] || renderState.size[1] !== size[1]) {
|
|
35928
|
+
if (renderState && renderState.size && (renderState.size[0] !== size[0] || renderState.size[1] !== size[1])) {
|
|
35930
35929
|
changed = true;
|
|
35931
35930
|
renderState.size = size;
|
|
35932
35931
|
}
|
|
@@ -36796,13 +36795,13 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
36796
36795
|
this.deactivate();
|
|
36797
36796
|
}
|
|
36798
36797
|
deactivate() {
|
|
36799
|
-
console.error("
|
|
36798
|
+
console.error("The function deactivate() must be implemented in subclasses");
|
|
36800
36799
|
}
|
|
36801
36800
|
render(options) {
|
|
36802
|
-
console.error("
|
|
36801
|
+
console.error("The function render() must be implemented in subclasses");
|
|
36803
36802
|
}
|
|
36804
36803
|
createDefaultElement() {
|
|
36805
|
-
console.error("
|
|
36804
|
+
console.error("The function createDefaultElement() must be implemented in subclasses");
|
|
36806
36805
|
}
|
|
36807
36806
|
};
|
|
36808
36807
|
var ControlCommon_default = ControlCommon;
|
|
@@ -36862,7 +36861,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
36862
36861
|
if (this.map) {
|
|
36863
36862
|
this.map.un("postrender", this.onPostRender);
|
|
36864
36863
|
}
|
|
36865
|
-
super.deactivate();
|
|
36866
36864
|
}
|
|
36867
36865
|
onPostRender(evt) {
|
|
36868
36866
|
if (this.map && this.element) {
|
|
@@ -48645,7 +48643,8 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48645
48643
|
this.removeListeners();
|
|
48646
48644
|
this.reset();
|
|
48647
48645
|
}
|
|
48648
|
-
|
|
48646
|
+
}
|
|
48647
|
+
render() {
|
|
48649
48648
|
}
|
|
48650
48649
|
};
|
|
48651
48650
|
var RoutingControl_default = RoutingControl;
|
|
@@ -48654,9 +48653,9 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48654
48653
|
var StopFinderControlCommon = class extends ControlCommon_default {
|
|
48655
48654
|
constructor(options) {
|
|
48656
48655
|
super(options);
|
|
48657
|
-
const { apiParams, apiKey, url } = options;
|
|
48656
|
+
const { apiParams, apiKey, url, placeholder } = options || {};
|
|
48658
48657
|
this.apiParams = { limit: 20, ...apiParams || {} };
|
|
48659
|
-
this.placeholder =
|
|
48658
|
+
this.placeholder = placeholder || "Search for a stop...";
|
|
48660
48659
|
const apiOptions = { apiKey };
|
|
48661
48660
|
if (url) {
|
|
48662
48661
|
apiOptions.url = url;
|
|
@@ -48664,6 +48663,8 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48664
48663
|
this.api = new StopsAPI_default(apiOptions);
|
|
48665
48664
|
this.abortController = new AbortController();
|
|
48666
48665
|
}
|
|
48666
|
+
deactivate() {
|
|
48667
|
+
}
|
|
48667
48668
|
render(featureCollection) {
|
|
48668
48669
|
const suggestions = featureCollection?.features || [];
|
|
48669
48670
|
if (!this.suggestionsElt) {
|
|
@@ -48920,10 +48921,10 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48920
48921
|
}
|
|
48921
48922
|
this.renderState = {
|
|
48922
48923
|
center: [x, y],
|
|
48923
|
-
zoom:
|
|
48924
|
-
rotation:
|
|
48925
|
-
visible:
|
|
48926
|
-
opacity:
|
|
48924
|
+
zoom: void 0,
|
|
48925
|
+
rotation: void 0,
|
|
48926
|
+
visible: void 0,
|
|
48927
|
+
opacity: void 0,
|
|
48927
48928
|
size: [0, 0]
|
|
48928
48929
|
};
|
|
48929
48930
|
super.loadMbMap();
|
|
@@ -48972,9 +48973,9 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48972
48973
|
}
|
|
48973
48974
|
};
|
|
48974
48975
|
|
|
48975
|
-
// src/ol/layers/MapboxStyleLayer.
|
|
48976
|
+
// src/ol/layers/MapboxStyleLayer.ts
|
|
48976
48977
|
var MapboxStyleLayer = class extends Layer_default4 {
|
|
48977
|
-
constructor(options
|
|
48978
|
+
constructor(options) {
|
|
48978
48979
|
super(options);
|
|
48979
48980
|
this.mapboxLayer = options.mapboxLayer;
|
|
48980
48981
|
this.disabled = false;
|
|
@@ -48998,11 +48999,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
48998
48999
|
}
|
|
48999
49000
|
}
|
|
49000
49001
|
attachToMap(map) {
|
|
49001
|
-
if (!this.mapboxLayer.map) {
|
|
49002
|
-
this.mapboxLayer
|
|
49002
|
+
if (this.mapboxLayer && !this.mapboxLayer.map) {
|
|
49003
|
+
this.mapboxLayer?.attachToMap(map);
|
|
49003
49004
|
}
|
|
49004
49005
|
super.attachToMap(map);
|
|
49005
|
-
if (!this.map) {
|
|
49006
|
+
if (!this.map || !this.mapboxLayer) {
|
|
49006
49007
|
return;
|
|
49007
49008
|
}
|
|
49008
49009
|
const { mbMap } = this.mapboxLayer;
|
|
@@ -49024,35 +49025,36 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49024
49025
|
this.onLoad();
|
|
49025
49026
|
}));
|
|
49026
49027
|
}
|
|
49027
|
-
detachFromMap(
|
|
49028
|
-
|
|
49029
|
-
|
|
49028
|
+
detachFromMap() {
|
|
49029
|
+
if (this.mapboxLayer?.mbMap) {
|
|
49030
|
+
const { mbMap } = this.mapboxLayer;
|
|
49030
49031
|
mbMap.off("load", this.onLoad);
|
|
49031
49032
|
this.removeStyleLayers();
|
|
49032
49033
|
}
|
|
49033
|
-
super.detachFromMap(
|
|
49034
|
+
super.detachFromMap();
|
|
49034
49035
|
}
|
|
49035
49036
|
addStyleLayers() {
|
|
49036
|
-
|
|
49037
|
-
if (!mbMap) {
|
|
49037
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49038
49038
|
return;
|
|
49039
49039
|
}
|
|
49040
|
+
const { mbMap } = this.mapboxLayer;
|
|
49040
49041
|
this.styleLayers.forEach((styleLayer) => {
|
|
49041
49042
|
const { id, source } = styleLayer;
|
|
49042
|
-
if (mbMap.getSource(source) && !mbMap.getLayer(id)) {
|
|
49043
|
+
if (mbMap.getSource(source) && id && !mbMap.getLayer(id)) {
|
|
49043
49044
|
mbMap.addLayer(styleLayer, this.beforeId);
|
|
49044
49045
|
}
|
|
49045
49046
|
});
|
|
49046
49047
|
this.applyLayoutVisibility();
|
|
49047
49048
|
}
|
|
49048
49049
|
removeStyleLayers() {
|
|
49049
|
-
|
|
49050
|
-
if (!mbMap) {
|
|
49050
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49051
49051
|
return;
|
|
49052
49052
|
}
|
|
49053
|
+
const { mbMap } = this.mapboxLayer;
|
|
49053
49054
|
this.styleLayers.forEach((styleLayer) => {
|
|
49054
|
-
|
|
49055
|
-
|
|
49055
|
+
const { id } = styleLayer;
|
|
49056
|
+
if (id && mbMap.getLayer(id)) {
|
|
49057
|
+
mbMap.removeLayer(id);
|
|
49056
49058
|
}
|
|
49057
49059
|
});
|
|
49058
49060
|
}
|
|
@@ -49061,6 +49063,9 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49061
49063
|
if (this.addDynamicFilters) {
|
|
49062
49064
|
this.addDynamicFilters();
|
|
49063
49065
|
}
|
|
49066
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49067
|
+
return;
|
|
49068
|
+
}
|
|
49064
49069
|
const { mbMap } = this.mapboxLayer;
|
|
49065
49070
|
const style = mbMap.getStyle();
|
|
49066
49071
|
if (style && this.styleLayersFilter) {
|
|
@@ -49069,8 +49074,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49069
49074
|
}
|
|
49070
49075
|
}
|
|
49071
49076
|
getFeatureInfoAtCoordinate(coordinate) {
|
|
49077
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49078
|
+
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
49079
|
+
}
|
|
49072
49080
|
const { mbMap } = this.mapboxLayer;
|
|
49073
|
-
if (!mbMap
|
|
49081
|
+
if (!mbMap.isStyleLoaded()) {
|
|
49074
49082
|
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
49075
49083
|
}
|
|
49076
49084
|
let layers = this.styleLayers || [];
|
|
@@ -49084,23 +49092,28 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49084
49092
|
layers: layers.map((layer) => layer && layer.id),
|
|
49085
49093
|
validate: false
|
|
49086
49094
|
}).then((featureInfo) => {
|
|
49087
|
-
const features = featureInfo.features.filter((feature2) =>
|
|
49095
|
+
const features = featureInfo.features.filter((feature2) => {
|
|
49096
|
+
return this.featureInfoFilter(feature2, this.map?.getView().getResolution());
|
|
49097
|
+
});
|
|
49088
49098
|
this.highlight(features);
|
|
49089
49099
|
return { ...featureInfo, features, layer: this };
|
|
49090
49100
|
});
|
|
49091
49101
|
}
|
|
49092
49102
|
setFilter(filter) {
|
|
49093
|
-
|
|
49094
|
-
if (!mbMap) {
|
|
49103
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49095
49104
|
return;
|
|
49096
49105
|
}
|
|
49106
|
+
const { mbMap } = this.mapboxLayer;
|
|
49097
49107
|
this.styleLayers.forEach(({ id }) => {
|
|
49098
|
-
if (mbMap.getLayer(id)) {
|
|
49108
|
+
if (id && filter && mbMap.getLayer(id)) {
|
|
49099
49109
|
mbMap.setFilter(id, filter);
|
|
49100
49110
|
}
|
|
49101
49111
|
});
|
|
49102
49112
|
}
|
|
49103
49113
|
setHoverState(features, state) {
|
|
49114
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49115
|
+
return;
|
|
49116
|
+
}
|
|
49104
49117
|
const { mbMap } = this.mapboxLayer;
|
|
49105
49118
|
if (!features || !mbMap) {
|
|
49106
49119
|
return;
|
|
@@ -49121,23 +49134,23 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49121
49134
|
});
|
|
49122
49135
|
}
|
|
49123
49136
|
select(features = []) {
|
|
49124
|
-
this.setHoverState(this.selectedFeatures, false);
|
|
49137
|
+
this.setHoverState(this.selectedFeatures || [], false);
|
|
49125
49138
|
this.selectedFeatures = features;
|
|
49126
|
-
this.setHoverState(this.selectedFeatures, true);
|
|
49139
|
+
this.setHoverState(this.selectedFeatures || [], true);
|
|
49127
49140
|
}
|
|
49128
49141
|
highlight(features = []) {
|
|
49129
|
-
const filtered = this.highlightedFeatures
|
|
49142
|
+
const filtered = this.highlightedFeatures?.filter((feature2) => !(this.selectedFeatures || []).map((feat) => feat.getId()).includes(feature2.getId())) || [];
|
|
49130
49143
|
this.setHoverState(filtered, false);
|
|
49131
49144
|
this.highlightedFeatures = features;
|
|
49132
49145
|
this.setHoverState(this.highlightedFeatures, true);
|
|
49133
49146
|
}
|
|
49134
49147
|
applyLayoutVisibility(evt) {
|
|
49135
49148
|
const { visible } = this;
|
|
49136
|
-
const { mbMap } = this.mapboxLayer;
|
|
49137
49149
|
const filterFunc = this.styleLayersFilter;
|
|
49138
|
-
if (!mbMap) {
|
|
49150
|
+
if (!this.mapboxLayer?.mbMap) {
|
|
49139
49151
|
return;
|
|
49140
49152
|
}
|
|
49153
|
+
const { mbMap } = this.mapboxLayer;
|
|
49141
49154
|
const style = mbMap.getStyle();
|
|
49142
49155
|
if (!style) {
|
|
49143
49156
|
return;
|
|
@@ -49650,7 +49663,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49650
49663
|
};
|
|
49651
49664
|
var fullTrajectoryStyle_default = fullTrajectorystyle;
|
|
49652
49665
|
|
|
49653
|
-
// src/ol/styles/fullTrajectoryDelayStyle.
|
|
49666
|
+
// src/ol/styles/fullTrajectoryDelayStyle.ts
|
|
49654
49667
|
var stroke = new Style_default({
|
|
49655
49668
|
zIndex: 2,
|
|
49656
49669
|
image: new Circle_default({
|
|
@@ -49868,7 +49881,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49868
49881
|
};
|
|
49869
49882
|
var RealtimeLayer_default = RealtimeLayer;
|
|
49870
49883
|
|
|
49871
|
-
// src/ol/layers/VectorLayer.
|
|
49884
|
+
// src/ol/layers/VectorLayer.ts
|
|
49872
49885
|
var VectorLayer2 = class extends Layer_default4 {
|
|
49873
49886
|
getFeatureInfoAtCoordinate(coordinate) {
|
|
49874
49887
|
let features = [];
|
|
@@ -49891,29 +49904,40 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49891
49904
|
};
|
|
49892
49905
|
var VectorLayer_default2 = VectorLayer2;
|
|
49893
49906
|
|
|
49894
|
-
// src/ol/layers/WMSLayer.
|
|
49907
|
+
// src/ol/layers/WMSLayer.ts
|
|
49895
49908
|
var WMSLayer = class extends Layer_default4 {
|
|
49896
|
-
constructor(options
|
|
49909
|
+
constructor(options) {
|
|
49897
49910
|
super(options);
|
|
49898
49911
|
this.abortController = new AbortController();
|
|
49899
49912
|
this.format = new GeoJSON_default();
|
|
49900
49913
|
}
|
|
49901
49914
|
getFeatureInfoUrl(coord) {
|
|
49915
|
+
if (!this.map) {
|
|
49916
|
+
return;
|
|
49917
|
+
}
|
|
49902
49918
|
const projection = this.map.getView().getProjection();
|
|
49903
49919
|
const resolution = this.map.getView().getResolution();
|
|
49904
|
-
if (this.olLayer
|
|
49905
|
-
return this.olLayer
|
|
49920
|
+
if (resolution && projection && this.olLayer?.getSource()?.getFeatureInfoUrl) {
|
|
49921
|
+
return this.olLayer?.getSource()?.getFeatureInfoUrl(coord, resolution, projection, {
|
|
49906
49922
|
info_format: "application/json",
|
|
49907
|
-
query_layers: this.olLayer
|
|
49923
|
+
query_layers: this.olLayer?.getSource()?.getParams().layers
|
|
49908
49924
|
});
|
|
49909
49925
|
}
|
|
49910
|
-
return false;
|
|
49911
49926
|
}
|
|
49912
49927
|
getFeatureInfoAtCoordinate(coordinate) {
|
|
49913
|
-
this.abortController
|
|
49928
|
+
this.abortController?.abort();
|
|
49914
49929
|
this.abortController = new AbortController();
|
|
49915
49930
|
const { signal } = this.abortController;
|
|
49916
|
-
|
|
49931
|
+
const url = this.getFeatureInfoUrl(coordinate);
|
|
49932
|
+
if (!url) {
|
|
49933
|
+
console.error("No url for the WMS layer.");
|
|
49934
|
+
return Promise.resolve({
|
|
49935
|
+
features: [],
|
|
49936
|
+
coordinate,
|
|
49937
|
+
layer: this
|
|
49938
|
+
});
|
|
49939
|
+
}
|
|
49940
|
+
return fetch(url, { signal }).then((resp) => resp.json()).then((r) => r.features).then((data) => ({
|
|
49917
49941
|
layer: this,
|
|
49918
49942
|
coordinate,
|
|
49919
49943
|
features: data.map((d) => this.format.readFeature(d))
|
|
@@ -49948,6 +49972,8 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49948
49972
|
getMapboxMapCopyrights: () => getMapboxMapCopyrights_default,
|
|
49949
49973
|
getMapboxRender: () => getMapboxRender,
|
|
49950
49974
|
getMaplibreRender: () => getMaplibreRender,
|
|
49975
|
+
getMercatorResolution: () => getMercatorResolution_default,
|
|
49976
|
+
getSourceCoordinates: () => getSourceCoordinates_default,
|
|
49951
49977
|
getTextCanvas: () => getTextCanvas,
|
|
49952
49978
|
getUTCDateString: () => getUTCDateString,
|
|
49953
49979
|
getUTCTimeString: () => getUTCTimeString,
|
|
@@ -49990,7 +50016,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49990
50016
|
};
|
|
49991
50017
|
var CopyrightControl_default2 = CopyrightControl2;
|
|
49992
50018
|
|
|
49993
|
-
// src/mapbox/layers/Layer.
|
|
50019
|
+
// src/mapbox/layers/Layer.ts
|
|
49994
50020
|
var Layer4 = class extends UserInteractionsLayerMixin_default(Layer2) {
|
|
49995
50021
|
attachToMap(map) {
|
|
49996
50022
|
super.attachToMap(map);
|
|
@@ -50011,10 +50037,10 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50011
50037
|
}
|
|
50012
50038
|
activateUserInteractions() {
|
|
50013
50039
|
this.deactivateUserInteractions();
|
|
50014
|
-
if (this.map && this.userInteractions && this.userClickInteractions && this.userClickCallbacks
|
|
50040
|
+
if (this.map && this.userInteractions && this.userClickInteractions && this.userClickCallbacks?.length) {
|
|
50015
50041
|
this.map.on("click", this.onUserClickCallback);
|
|
50016
50042
|
}
|
|
50017
|
-
if (this.map && this.userInteractions && this.userHoverInteractions && this.userHoverCallbacks
|
|
50043
|
+
if (this.map && this.userInteractions && this.userHoverInteractions && this.userHoverCallbacks?.length) {
|
|
50018
50044
|
this.map.on("mousemove", this.onUserMoveCallback);
|
|
50019
50045
|
}
|
|
50020
50046
|
}
|
|
@@ -50523,18 +50549,8 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50523
50549
|
}
|
|
50524
50550
|
var es_default6 = transformRotate;
|
|
50525
50551
|
|
|
50526
|
-
// src/mapbox/utils.
|
|
50527
|
-
var
|
|
50528
|
-
const bounds = map.getBounds().toArray();
|
|
50529
|
-
const a = fromLonLat(bounds[0]);
|
|
50530
|
-
const b = fromLonLat(bounds[1]);
|
|
50531
|
-
const extent = [...a, ...b];
|
|
50532
|
-
const { width, height } = map.getCanvas();
|
|
50533
|
-
const xResolution = getWidth(extent) / width;
|
|
50534
|
-
const yResolution = getHeight(extent) / height;
|
|
50535
|
-
return Math.max(xResolution, yResolution);
|
|
50536
|
-
};
|
|
50537
|
-
var getSourceCoordinates = (map, pixelRatio) => {
|
|
50552
|
+
// src/mapbox/utils/getSourceCoordinates.ts
|
|
50553
|
+
var getSourceCoordinates = (map, pixelRatio = 1) => {
|
|
50538
50554
|
const { width, height } = map.getCanvas();
|
|
50539
50555
|
const leftTop = map.unproject({ x: 0, y: 0 });
|
|
50540
50556
|
const leftBottom = map.unproject({ x: 0, y: height / pixelRatio });
|
|
@@ -50550,8 +50566,22 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50550
50566
|
[leftBottom.lng, leftBottom.lat]
|
|
50551
50567
|
];
|
|
50552
50568
|
};
|
|
50569
|
+
var getSourceCoordinates_default = getSourceCoordinates;
|
|
50553
50570
|
|
|
50554
|
-
// src/mapbox/
|
|
50571
|
+
// src/mapbox/utils/getMercatorResolution.ts
|
|
50572
|
+
var getMercatorResolution = (map) => {
|
|
50573
|
+
const bounds = map.getBounds().toArray();
|
|
50574
|
+
const a = fromLonLat(bounds[0]);
|
|
50575
|
+
const b = fromLonLat(bounds[1]);
|
|
50576
|
+
const extent = [...a, ...b];
|
|
50577
|
+
const { width, height } = map.getCanvas();
|
|
50578
|
+
const xResolution = getWidth(extent) / width;
|
|
50579
|
+
const yResolution = getHeight(extent) / height;
|
|
50580
|
+
return Math.max(xResolution, yResolution);
|
|
50581
|
+
};
|
|
50582
|
+
var getMercatorResolution_default = getMercatorResolution;
|
|
50583
|
+
|
|
50584
|
+
// src/mapbox/layers/RealtimeLayer.ts
|
|
50555
50585
|
var RealtimeLayer2 = class extends RealtimeLayerMixin_default(Layer_default5) {
|
|
50556
50586
|
constructor(options = {}) {
|
|
50557
50587
|
super({
|
|
@@ -50567,15 +50597,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50567
50597
|
if (!map) {
|
|
50568
50598
|
return;
|
|
50569
50599
|
}
|
|
50570
|
-
|
|
50571
|
-
super.attachToMap(map, {
|
|
50572
|
-
width: canvas2.width / this.pixelRatio,
|
|
50573
|
-
height: canvas2.height / this.pixelRatio
|
|
50574
|
-
});
|
|
50600
|
+
super.attachToMap(map);
|
|
50575
50601
|
this.source = {
|
|
50576
50602
|
type: "canvas",
|
|
50577
50603
|
canvas: this.canvas,
|
|
50578
|
-
coordinates:
|
|
50604
|
+
coordinates: getSourceCoordinates_default(map, this.pixelRatio),
|
|
50579
50605
|
animate: true,
|
|
50580
50606
|
attribution: this.copyrights && this.copyrights.join(", ")
|
|
50581
50607
|
};
|
|
@@ -50642,17 +50668,23 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50642
50668
|
...evt
|
|
50643
50669
|
});
|
|
50644
50670
|
}
|
|
50645
|
-
renderTrajectories(noInterpolate) {
|
|
50671
|
+
renderTrajectories(noInterpolate = false) {
|
|
50646
50672
|
if (!this.map) {
|
|
50647
50673
|
return;
|
|
50648
50674
|
}
|
|
50675
|
+
if (!this.pixelRatio) {
|
|
50676
|
+
this.pixelRatio = 1;
|
|
50677
|
+
}
|
|
50649
50678
|
const { width, height } = this.map.getCanvas();
|
|
50650
50679
|
const center = this.map.getCenter();
|
|
50651
50680
|
const leftBottom = this.map.unproject({
|
|
50652
50681
|
x: 0,
|
|
50653
50682
|
y: height / this.pixelRatio
|
|
50654
50683
|
});
|
|
50655
|
-
const rightTop = this.map.unproject({
|
|
50684
|
+
const rightTop = this.map.unproject({
|
|
50685
|
+
x: width / this.pixelRatio,
|
|
50686
|
+
y: 0
|
|
50687
|
+
});
|
|
50656
50688
|
const coord0 = es_default6(point([leftBottom.lng, leftBottom.lat]), -this.map.getBearing(), {
|
|
50657
50689
|
pivot: [center.lng, center.lat]
|
|
50658
50690
|
}).geometry.coordinates;
|
|
@@ -50678,7 +50710,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50678
50710
|
return super.getRefreshTimeInMs(this.map.getZoom());
|
|
50679
50711
|
}
|
|
50680
50712
|
getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
50681
|
-
const resolution =
|
|
50713
|
+
const resolution = getMercatorResolution_default(this.map);
|
|
50682
50714
|
return super.getFeatureInfoAtCoordinate(coordinate, {
|
|
50683
50715
|
resolution,
|
|
50684
50716
|
...options
|
|
@@ -50706,10 +50738,10 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50706
50738
|
onMove() {
|
|
50707
50739
|
this.renderTrajectories();
|
|
50708
50740
|
}
|
|
50709
|
-
renderTrajectoriesInternal(viewState, noInterpolate) {
|
|
50741
|
+
renderTrajectoriesInternal(viewState, noInterpolate = false) {
|
|
50710
50742
|
const render = super.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
50711
50743
|
if (render && this.map.style) {
|
|
50712
|
-
const extent =
|
|
50744
|
+
const extent = getSourceCoordinates_default(this.map, this.pixelRatio);
|
|
50713
50745
|
const source = this.map.getSource(this.key);
|
|
50714
50746
|
if (source) {
|
|
50715
50747
|
source.setCoordinates(extent);
|