Skip to content

Fix TypeError in Atlas Panels: Cannot read properties of undefined (reading 'getLayer') #390

@SvenVw

Description

@SvenVw

Issue:
A TypeError: Cannot read properties of undefined (reading 'getLayer') was observed in fdm-app/app/components/blocks/atlas/atlas-panels.tsx.
This error occurs when the updatePanel function attempts to access map.getLayer(layer) before the map's style object has been fully initialized or after it has been removed. Specifically, map.getLayer relies on this.style, which can be undefined during these states.

Cause:
The map object exists, but its internal style reference (this.style) is undefined at the moment getLayer is called, leading to a crash when accessing getLayer.

Fix:
Added a guard clause to check if map.getStyle() returns a valid object before attempting to call map.getLayer().

// Modified in fdm-app/app/components/blocks/atlas/atlas-panels.tsx
if (!map.getStyle() || !map.getLayer(layer)) return

This ensures that layer queries are only attempted when the map is in a valid state to handle them.

Metadata

Metadata

Assignees

Labels

branch:mainAn issue, affecting the main branch, that requires an hotfixbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions