Error when removing a layer
See original GitHub issueHi,
Sometimes, I got this error when I try to remove a layer from my map.
mapbox-gl.js:411 The layer '5948b9f3b506c203ba0d7baa' does not exist in the map's style and cannot be queried for features.
Uncaught TypeError: Cannot read property 'length' of undefined
Here is my code :
render() {
console.log(this.state.locations)
return (
<div>
<Map
style="mapbox://styles/mapbox/streets-v9"
containerStyle={{
height: '100vh',
width: '100vw'
}}>
{this.state.locations.length > 0 &&
this.state.locations.map(l =>
<Layer type="symbol" id={l.id} layout={{ 'icon-image': 'marker-15' }} key={l.id}>
<Feature coordinates={[getFloat(l.longitude), getFloat(l.latitude)]} />
</Layer>
)}}
</Map>
</div>
)
}
On my page, I have a menu to select and unselect locations and it’s modifying my locations array. When I come on my page for the first time, my locations array is empty but I don’t get any error. When I select a locations it’s displaying a layer correctly on my map, but when I unselect some locations and remove it from my array, mapbox-gl.js is throwing this error. It seems to happen a bit randomly.
Thanks for your help.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Cannot remove a layer from a group in TOC in Pro
The workaround is to remove the whole group layer, then "undo" the remove. After this, i can remove layers from the group, but...
Read more >Code error - remove layer using python - GIS Stack Exchange
Code error - remove layer using python ... Have you got an mxd in your list that has no layers, or perhaps the...
Read more >Error: Can not execute remove on an inactive layer - Mocha Pro
I have four total layers and all of them are active. My remove, my background, one foreground layer and a layer I used...
Read more >Error Deleting an App layer due to a Template
Location: UdmcSilverlight.Modules.Layers.Wizards.Delete.ViewModels.ContainerDeleteViewModel Message: 2 Templates are using layer version '1' Details: Remove the ...
Read more >Error in removing the first layer of keras model - Stack Overflow
I was not able to recreate the error you were facing. May be you can share the reproducible code. Below options I have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the underlying bug: https://github.com/mapbox/mapbox-gl-js/issues/5145. The fix should be in the next mapbox-gl-js release (0.40.0).
Did you investigate the error in the above comment?