deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] MapboxOverlay throw id already exists when interleaved=true

Open chunlampang opened this issue 1 year ago • 7 comments

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

chunlampang avatar Jul 24 '24 04:07 chunlampang

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

moong23 avatar Jul 25 '24 08:07 moong23

Thanks for bringing this to our attention. I provided a reproduction on the upstream issue thread.

Pessimistress avatar Jul 27 '24 01:07 Pessimistress

FYI same error occurs with previous major deck.gl version. That is

dekc avatar Aug 13 '24 23:08 dekc

@dekc this is a Mapbox bug, not deck.gl's. It's been acknowledged by Mapbox.

Pessimistress avatar Aug 13 '24 23:08 Pessimistress

In mapbox-gl 3.6.0, they solved the bug, but created another error. TypeError: Cannot read properties of undefined (reading 'setProps')

chunlampang avatar Aug 15 '24 06:08 chunlampang

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

aemonm avatar Aug 19 '24 21:08 aemonm

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

chunlampang avatar Aug 21 '24 07:08 chunlampang