Closed linze99 closed 3 months ago
I think this is because mapbox has changed the return value of Map.getLayer() function: the versions before 3.6.0 are:
getLayer<T extends LayerSpecification>(id: string): T | undefined {
if (!this._isValidId(id)) {
return null;
}
//it returns a layer object
const layer = this.style.getOwnLayer(id);
return layer ? layer.serialize() as T : undefined;
}
but from version 3.6.0:
getLayer<T extends LayerSpecification | CustomLayerInterface>(id: string): T | undefined {
if (!this._isValidId(id)) {
return null;
}
const layer = this.style.getOwnLayer(id);
if (!layer) return;
//it returns an implementation directly
if (layer.type === 'custom') return (layer as CustomStyleLayer).implementation as T;
return layer.serialize() as T;
}
so i changed the resolveLayers() function to this:
// Step 2: add missing layers
for (const layer of layers) {
const mapboxLayer = map.getLayer(layer.id) as MapboxLayer<Layer>;
if (mapboxLayer) {
// @ts-expect-error not typed
mapboxLayer.setProps(layer.props);
//mapboxLayer.implementation.setProps(layer.props);
} else {
map.addLayer(
new MapboxLayer({id: layer.id, deck}),
// @ts-expect-error beforeId is not defined in LayerProps
layer.props.beforeId
);
}
}
it works fine!
Thanks for investigating this. I'll release a patch to handle this change.
@Pessimistress that would be awesome!! Can you share any update on the progress?
Description
When setting interleaved=true, deck.gl raise an exception: undefined is not an object (evaluating 'mapboxLayer.implementation.setProps') and the line features on mapbox are dispeared.
Flavors
Expected Behavior
Steps to Reproduce
I created a demo project at https://codepen.io/Ze-Lin-the-encoder/pen/eYXXdZd
Environment
Logs
No response