maplibre / ngx-maplibre-gl

Angular binding of maplibre-gl
https://maplibre.org/ngx-maplibre-gl/
MIT License
77 stars 26 forks source link

`MarkersForClustersComponent.updateCluster` continuously called #190

Closed marcjulian closed 3 months ago

marcjulian commented 3 months ago

MarkersForClustersComponent.updateCluster is continuously called, even when nothing changes in the UI (no move, zoom etc on the map). This was noticed because of #188 - https://github.com/maplibre/ngx-maplibre-gl/pull/189#issuecomment-2306913912.

When logging updateCluster we will see logs printed without any changes in the UI. This might be related to #178, before the PR updateCluster is only called while interacting with the map (map move, zoom).

https://github.com/maplibre/ngx-maplibre-gl/blob/921a598a7272b96f0919d4ebe66871cb5ba2eb51/projects/ngx-maplibre-gl/src/lib/markers-for-clusters/markers-for-clusters.component.ts#L131-L166

n-elhk commented 3 months ago
    afterNextRender(async () => {
      const earthquakes: GeoJSON.FeatureCollection = (await import(
        "./earthquakes.geo.json"
      )) as any;
      timer = setInterval(() => {
        if (earthquakes.features.length) {
          earthquakes.features.pop();
        }
        this.earthquakes.set({ ...earthquakes });
      }, 500);
    });

There is a setInterval in ngx-cluster-html.component.ts

Every 500ms its update the cluster

HarelM commented 3 months ago

Apparently so... this was introduced a long time ago. Closing this issue now, hopefully this was only a "panic attack" kind of thing...