ReactMapboxGl style switching: The layer 'layer-1' does not exist in the map's style and cannot be queried for features.
See original GitHub issue<ReactMapboxGl
style={getMapStyle()}
>
<Layer
type="line"
layout={{ 'line-cap': 'round', 'line-join': 'round' }}
>
<Feature coordinates={props.coordinates} />
</Layer>
</ReactMapboxGl>
If I have the layer object, the following error is produced when I switch Map styles (getMapStyle() returns a different style…in this case it’s from ‘mapbox://styles/mapbox/streets-v9’ to ‘mapbox://styles/mapbox/satellite-streets-v9’) “The layer ‘layer-1’ does not exist in the map’s style and cannot be queried for features.”
There’s also the following error trace:
Uncaught TypeError: Cannot read property 'forEach' of undefined
at e.Layer._this.onMouseMove (eval at <anonymous> (bundle.js:10513), <anonymous>:76:21)
at e.Evented.fire (eval at <anonymous> (bundle.js:10483), <anonymous>:237:700)
at h (eval at <anonymous> (bundle.js:10483), <anonymous>:183:1330)
at HTMLDivElement.a (eval at <anonymous> (bundle.js:10483), <anonymous>:183:788)
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (20 by maintainers)
Top Results From Across the Web
Mapbox - Changing map style causes Directions to not work ...
When you "change a map's style", you're essentially removing all the existing sources and layers, and adding new ones. So it is removing...
Read more >Change a map's style | Mapbox GL JS
When the user clicks a style name, it uses setStyle to redraw the map using the style URL associated with that option. The...
Read more >mapbox show zoom controls
Show your own MapBox map styles & 3D buildings inside your bubble app. Such as mkdir -p, cp -r, and rm -rf. If...
Read more >react-mapbox-gl - npm
Proxy components (proxy between React and Mapbox API). ReactMapboxGL; Layer & Feature. property symbol displays a mapbox symbol. property line ...
Read more >Using Mapbox GL JS with React - LogRocket Blog
Every time I try to use layers and features, I get a “Module not found: Can't resolve 'react-mapbox-gl'”. Is this a create react...
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
btw this issue (or a very similar one) will also manifest itself not just when changing styles, but also for example:
I was playing with mapbox-gl and found out that the problem is actually coming from
react-mapbox-gl
, I will work on it asap.https://jsfiddle.net/alex3165/acr3ykz5/