UI: Map widget - fix map layers load event.

This commit is contained in:
Igor Kulikov 2025-03-13 18:07:41 +02:00
parent a640ee11d9
commit a8ae13faea
4 changed files with 22 additions and 5 deletions

View File

@ -61,7 +61,7 @@
"leaflet": "1.9.4",
"leaflet-polylinedecorator": "1.6.0",
"leaflet-providers": "2.0.0",
"leaflet.gridlayer.googlemutant": "0.14.1",
"leaflet.gridlayer.googlemutant": "0.15.0",
"leaflet.markercluster": "1.5.3",
"libphonenumber-js": "^1.11.15",
"maplibre-gl": "^5.2.0",

View File

@ -772,6 +772,9 @@ class MapLibreGLLayer extends L.Layer implements TB.MapLibreGL.MapLibreGLLayer {
attributionControl: false
});
this._glMap = new MapLibreGLMap(options);
this._glMap.once('load', () => {
this.fire('load');
});
this._glMap.setMaxBounds(null);
this._transformGL(this._glMap);
this._actualCanvas = this._glMap._canvas;

View File

@ -116,8 +116,22 @@ export abstract class TbMapLayer<S extends MapLayerSettings> {
map((referenceLayer) => {
if (referenceLayer) {
const layer = L.featureGroup();
let baseLayerLoaded = false;
let referenceLayerLoaded = false;
baseLayer.addTo(layer);
referenceLayer.addTo(layer);
baseLayer.once('load', () => {
baseLayerLoaded = true;
if (referenceLayerLoaded) {
layer.fire('load');
}
});
referenceLayer.once('load', () => {
referenceLayerLoaded = true;
if (baseLayerLoaded) {
layer.fire('load');
}
});
return {
layer,
attribution: !!baseLayer.getAttribution() || !!referenceLayer.getAttribution()

View File

@ -6667,10 +6667,10 @@ leaflet-rotatedmarker@^0.2.0:
resolved "https://registry.yarnpkg.com/leaflet-rotatedmarker/-/leaflet-rotatedmarker-0.2.0.tgz#4467f49f98d1bfd56959bd9c6705203dd2601277"
integrity sha512-yc97gxLXwbZa+Gk9VCcqI0CkvIBC9oNTTjFsHqq4EQvANrvaboib4UdeQLyTnEqDpaXHCqzwwVIDHtvz2mUiDg==
leaflet.gridlayer.googlemutant@0.14.1:
version "0.14.1"
resolved "https://registry.yarnpkg.com/leaflet.gridlayer.googlemutant/-/leaflet.gridlayer.googlemutant-0.14.1.tgz#c282209aa1a39eb2f87d8aaa4e9894181c9e20a0"
integrity sha512-/OYxEjmgxO1U1KOhTzg+m8c0b95J0943LU8DXQmdJu/x2f+1Ur78rvEPO2QCS0cmwZ3m6FvE5I3zXnBzJNWRCA==
leaflet.gridlayer.googlemutant@0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/leaflet.gridlayer.googlemutant/-/leaflet.gridlayer.googlemutant-0.15.0.tgz#7a32d949578695b8aa8fa5fd11b40bd7a6ce6c23"
integrity sha512-kA5jCOBhCPigyue6YpZMhXMVYA1hM2pDIaJ6u0wSSiSZ2TQ4kZfKuhwkIexcadJfs0BP4FyhZIDZC7hmTlvjOA==
leaflet.markercluster@1.5.3:
version "1.5.3"