Skip to content

Bug: mgl-layer does not unregister source #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
radacovsky opened this issue Apr 20, 2022 · 1 comment
Open

Bug: mgl-layer does not unregister source #362

radacovsky opened this issue Apr 20, 2022 · 1 comment

Comments

@radacovsky
Copy link

Hello.
I have a layer with dedicated/dynamic source. The layer is added using *ngIf.

<mgl-layer *ngIf="selectedFeature" id="selectedLayer" type="fill" [source]="{
type: 'geojson',
data: selectedFeature
}" [paint]="selectedPaint">

If I add a layer, then remove it and add again I have the following error:

17:12:04.667 ERROR Error: There is already a source with this ID addSource mapbox-gl.js:35 addLayer mapbox-gl.js:35 addLayer mapbox-gl.js:35 addLayer ngx-mapbox-gl.js:215 Angular 3 addLayer ngx-mapbox-gl.js:208 init ngx-mapbox-gl.js:1526 sub ngx-mapbox-gl.js:1452 RxJS 33 ngOnInit ngx-mapbox-gl.js:1452 Angular 33 RxJS 5 Angular 22 GeojsonFeaturePickerComponent_ng_container_0_div_4_ng_container_7_button_4_Template geojson-feature-picker.component.html:35 Angular 23 [core.js:6210:12](webpack:///node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js) Angular 3 RxJS 5 Angular 20 RxJS 34 ngOnInit ngx-mapbox-gl.js:1452

By looking into the sorce code I can see that the layer is unregistered from mapbox but the connected source not. The connected source should be removed as well. Maybe there should be a flag to allow source unregistering in case other users use reusable sources.

@radacovsky
Copy link
Author

Also, I noticed that MapService.addLayer creates bindings for callbacks but MapService.removeLayer does not remove them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant