From d9a9d750de85fe7f58ab2d03b15fc7ae3e9003fa Mon Sep 17 00:00:00 2001 From: andrekir Date: Sun, 6 Oct 2024 05:40:24 -0300 Subject: [PATCH] fix: map cluster initialization and marker updates - prevents duplicate `RadiusMarkerClusterer` overlays - adds cluster `invalidate()` after marker updates --- .../java/com/geeksville/mesh/ui/map/MapFragment.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt index e1a80d11..49f8bf61 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt @@ -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)