Skip to content
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

"CannotAddLayerException: Cannot add layer twice" when removing a layer **by id** and adding it again #3101

Open
sargunv opened this issue Dec 19, 2024 · 0 comments
Labels

Comments

@sargunv
Copy link
Collaborator

sargunv commented Dec 19, 2024

MapLibre Android Version

11.7.1

Android SDK Version

35

Device

Galaxy Z Fold 6, Pixel 8 Pro, Simulator

What happened?

When removing a layer by ID and adding it again, CannotAddLayerException is thrown. I expect it to work the same as removing a layer by reference (style.removeLayer(style.getLayer("water")!!))

Steps to reproduce

This throws the exception:

map.setStyle(
    Style.Builder().fromUri(...)
) { style ->
    val waterLayer = style.getLayer("water")!!
    style.removeLayer("water")
    style.addLayer(waterLayer)
}

This does not throw the exception:

map.setStyle(
    Style.Builder().fromUri(...)
) { style ->
    val waterLayer = style.getLayer("water")!!
    style.removeLayer(waterLayer)
    style.addLayer(waterLayer)
}

Renderer

OpenGL (choose this if you are unsure)

Relevant log output

Additional context

Recent Slack thread where a user encountered this: https://osmus.slack.com/archives/C04G140P9U6/p1734124243679559

Older Slack thread where I encountered this and found the workaround: https://osmus.slack.com/archives/C06U5MM097B/p1731481107077449?thread_ts=1731313912.938259&cid=C06U5MM097B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant