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

Overlay is not replaced after adding it multiple times #1938

Open
Psijic opened this issue Sep 27, 2023 · 1 comment
Open

Overlay is not replaced after adding it multiple times #1938

Psijic opened this issue Sep 27, 2023 · 1 comment

Comments

@Psijic
Copy link

Psijic commented Sep 27, 2023

Currently overlays are not replaced and you can add multiple clones.
Suppose, it needs to change List<Overlay> overlays(); to Set and rewrite overlays hash and equals methods like in data class at least.
Need to use such construction for every overlay now:

 val indexToRemove = mapView.overlays.indexOfFirst { it is RadiusMarkerClusterer }
 if (indexToRemove != -1) mapView.overlays[indexToRemove] = cluster else mapView.overlays.add(cluster)
@Psijic Psijic changed the title Overlay is not replaced after adding same multiple times Overlay is not replaced after adding it multiple times Sep 27, 2023
@emandtf
Copy link

emandtf commented Jan 16, 2024

I don't think it's a bug.
Calling to "List overlays()" must be disallowed outside osmdroid library.
You can manage Layers by using normal List methods (add, remove, get, set, etc...) and if you don't want to add a Layer twice, you have to prev remove the existent and then add it again like in any normal ArrayList.
Arrays or Lists normally allows clones without any issue.

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

No branches or pull requests

2 participants