From 73d820d900d148d116f22e21fe20a61dfef766ff Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Tue, 4 May 2021 22:10:24 +0200 Subject: [PATCH] improving map: only loading map icon if visible --- .../lightbox.map.gallery.component.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts b/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts index 4a8e50e1..fcc44321 100644 --- a/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts +++ b/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -254,22 +254,24 @@ export class GalleryMapLightboxComponent implements OnChanges { // Setting photo icon if (Config.Client.Map.useImageMarkers === true) { - const iconTh = this.thumbnailService.getIcon(new MediaIcon(p)); - this.thumbnailsOnLoad.push(iconTh); - iconTh.Visible = true; - const setIcon = () => { - mkr.setIcon(icon({ - iconUrl: iconTh.Src, - iconSize: this.usedIconSize, // size of the icon - })); - mkr.options.alt = p.name; - }; + mkr.on('add', () => { + const iconTh = this.thumbnailService.getIcon(new MediaIcon(p)); + this.thumbnailsOnLoad.push(iconTh); + iconTh.Visible = true; + const setIcon = () => { + mkr.setIcon(icon({ + iconUrl: iconTh.Src, + iconSize: this.usedIconSize, // size of the icon + })); + mkr.options.alt = p.name; + }; + if (iconTh.Available === true) { + setIcon(); + } else { + iconTh.OnLoad = setIcon; + } + }); - if (iconTh.Available === true) { - setIcon(); - } else { - iconTh.OnLoad = setIcon; - } } }); if (this.gpxFiles) {