-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map#getLayer
returns undefined
for the custom
layer type
#13239
Comments
@moong23, could you please make a standalone reproduction of this? I.e., using only GL JS? |
@stepankuzmin well haven't tried to use GL JS only, but i'll try my best 😃 |
deck.gl uses Here is a minimal reproduction: const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
accessToken: MAPBOX_TOKEN
});
const layer = {
id: 'my-layer',
type: 'custom',
onAdd() {
console.log(`Layer ${this.id} is added`);
},
onRemove() {
console.log(`Layer ${this.id} is removed`);
},
render() {}
}
map.on('styledata', () => {
if (map.getLayer(layer.id)) {
// already added
} else {
map.addLayer(layer);
}
}); Log:
|
thx @Pessimistress |
Thanks, @Pessimistress. This is a bug. |
Map#getLayer
returns undefined
for the custom
layer type
mapbox-gl-js version: 3.5.2
browser: chrome
Steps to Trigger Behavior
interleaved
mode.Link to Demonstration
https://codesandbox.io/p/sandbox/jovial-wing-f8y2xl?file=%2Fsrc%2FCustomMap.tsx%3A14%2C1
(think you need to log in to codesandbox to see this demo. Let me know if you want me to make a github repo-ed demo)
Expected Behavior
No re-rendering existing layer on state changes
Actual Behavior
when viewState changes, the layer tries to mount again.
The text was updated successfully, but these errors were encountered: