[Bug] MapboxOverlay throw id already exists when interleaved=true
Description
Any layer inside MapboxOverlay will throw Error: Layer with id "layer-id" already exists on this map when interleaved is set to true.
Flavors
- [ ] Script tag
- [ ] React
- [ ] Python/Jupyter notebook
- [X] MapboxOverlay
- [ ] GoogleMapsOverlay
- [ ] CartoLayer
- [ ] ArcGIS
Expected Behavior
No error
Steps to Reproduce
const { MapboxOverlay, TextLayer } = deck;
mapboxgl.accessToken = 'token';
const map = new mapboxgl.Map({
container: document.body,
style: "mapbox://styles/mapbox/light-v11",
center: [0, 0],
zoom: 10,
});
map.on('load', () => {
const mapboxOverlay = new MapboxOverlay({
interleaved: true,
layers: [
new TextLayer({
id: 'TextLayer1',
getText: (d) => d.name,
getPosition: (d) => d.position,
data: [
{ name: 'Hiiiii', position: [0, 0] }
]
})
]
});
map.addControl(mapboxOverlay);
});
Environment
[email protected] [email protected]
Logs
No response
It seems like the issue is with [email protected]. I found that no errors occur with version 3.5.1 of mapbox-gl. I've also reported the bug to the mapbox-gl library.
https://github.com/mapbox/mapbox-gl-js/issues/13239
Thanks for bringing this to our attention. I provided a reproduction on the upstream issue thread.
FYI same error occurs with previous major deck.gl version. That is
@dekc this is a Mapbox bug, not deck.gl's. It's been acknowledged by Mapbox.
In mapbox-gl 3.6.0, they solved the bug, but created another error.
TypeError: Cannot read properties of undefined (reading 'setProps')
Follwoing up on @chunlampang, specifically the issue is now caused by this section of code:
function DeckGLOverlay(props: DeckProps) {
const overlay = useControl<MapboxOverlay>(() => new MapboxOverlay(props));
overlay.setProps(props);
return null;
}
which is found here in the MapboxOverlay section of the docs. Issue is present in mapbox-gl: 3.6.0
In mapbox-gl 3.6.0, they solved the bug, but created another error.
TypeError: Cannot read properties of undefined (reading 'setProps')
Someone opened another issue for this case. https://github.com/visgl/deck.gl/issues/9086