fix: map cluster initialization and marker updates

- prevents duplicate `RadiusMarkerClusterer` overlays
- adds cluster `invalidate()` after marker updates
pull/1292/head
andrekir 2024-10-06 05:40:24 -03:00
rodzic be6ea79c04
commit d9a9d750de
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -121,10 +121,9 @@ private fun MapView.UpdateMarkers(
overlays.removeAll { it is MarkerWithLabel }
// overlays.addAll(nodeMarkers + waypointMarkers)
overlays.addAll(waypointMarkers)
nodeClusterer.getItems().clear()
nodeMarkers.forEach {
nodeClusterer.add(it)
}
nodeClusterer.items.clear()
nodeClusterer.items.addAll(nodeMarkers)
nodeClusterer.invalidate()
}
/**
@ -491,7 +490,9 @@ fun MapView(
if (myLocationOverlay != null && overlays.none { it is MyLocationNewOverlay }) {
overlays.add(myLocationOverlay)
}
map.overlays.add(nodeClusterer)
if (overlays.none { it is RadiusMarkerClusterer }) {
overlays.add(nodeClusterer)
}
addCopyright() // Copyright is required for certain map sources
createLatLongGrid(false)