1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Removing empty layers from map control #587 #647

This commit is contained in:
Patrik J. Braun 2023-03-21 19:59:47 +01:00
parent 50449e6b9c
commit 51a473f4f0

View File

@ -425,7 +425,12 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
}
clearPath(): void {
this.pathLayersConfigOrdered.forEach(p => p.layer.clearLayers());
this.pathLayersConfigOrdered.forEach(p => {
p.layer.clearLayers();
this.mapLayerControl.removeLayer(
p.layer
);
});
}
@ -554,10 +559,7 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
// Add layer to the map
this.pathLayersConfigOrdered.filter(pl => pl.layer.getLayers().length > 0).forEach((pl) => {
// make sure it does not appear twice
this.mapLayerControl.removeLayer(
pl.layer
);
this.mapLayerControl.addOverlay(
pl.layer,
pl.name