ngx-mapbox-gl
ngx-mapbox-gl copied to clipboard
[BUG] dynamic change of clusterMaxZoom in mgl-geojson-source not working
BUG:
Updating the clusterMaxZoom
in mgl-geojson-source
is throwing an error
Error:
Assumption:
when I debugged the library code , the code seems not removing the layers related before updating ( removing / adding again ) the source.
BUG reproduced:
Here is a stackblitz where I reproduced the BUG: https://stackblitz.com/edit/ngx-mapbox-gl-playground-jqudva
@Wykks is this is a known bug ? (correct me if its not a bug please)
a workaround I did , is triggering the removal /addition of sources layers in the correct order , before and after changing the vehiclesClusterMaxZoom,
sequence in ts file
this.toggleLayerRendering({isRendered: false});
this.toggleSourceRendering({isRendered: false});
setTimeout(() => {
this.clusterMaxZoom = clusterMaxZoom;
this.toggleSourceRendering({isRendered: true});
this.toggleLayerRendering({isRendered: true});
}, 0);
and then the layers/source is rendered according to the toggles :
html file
<mgl-geojson-source
*ngIf="isSourceRendered"
[id]="source"
[data]="source.data"
[cluster]="source.cluster"
[clusterMaxZoom]="vehiclesClusterMaxZoom". // <= value to update dynamically
[clusterRadius]="source.clusterRadius"
>
</mgl-geojson-source>
<mgl-layer
*ngIf="isLayerRendered"
[id]="layer.id"
[type]="layer.type"
[paint]="layer.paint"
[filter]="layer.filter"
[layout]="layer.layout"
[source]="layer.source"
>
</mgl-layer>
@firashamila33 Try updating your sample to the latest version of ngx-mapbox-gl, mapbox-gl & @types/mapbox-gl and then let me know if the problem still exists.
@dmytro-gokun , still same issue here , updated in the stackblitz example and also in my project , but same issue
@firashamila33 Thanks for update. I'll try to look at this issue shortly.
@dmytro-gokun any updates on this ?