Reusing an id of a previously removed layer for a layer of a different type causes an error
@mourner is already working on this.
Since May 28, 2020.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hello I am using mapboxGL.js in an application where we add a fill extrusion layer on a button click. But I get some errors in the console. Here the description and a minimal working example. Thank you so much for your work and time!
**mapbox-gl-js version** : v1.10.1
**browser**: Firefox 76.0.1 but also in Chrome though error description is different.
### Steps to Trigger Behavior
0. Remove the buildings layer
1. Add a fill-extrusion layer of the buildings with the same layer id.
TypeError r is undefined is thrown in the console
2. Remove the fill-extrusion layer
3. Add a fill layer with the same layer Id
TypeError r is undefined is thrown in the console
In my main application I get the **TypeError u is undefined** when removing the fill-extrusion layer and adding a fill layer. I get the **TypeError r is undefined** when removing the fill layer and adding the fill-extrusion layer.
I couldn't reproduce the **TypeError u is undefined** error in the minimal example though.
### Link to Demonstration
https://jsbin.com/keluvefulo/1/edit?html,console,output
Just press the buttons in order to reproduce the error
### Expected Behavior
To not throw errors in the console.
### Actual Behavior
The layer adding and removing works on the map as expected. But I get a lot of errors in the console.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.