@@ -78,20 +78,24 @@ struct CustomMap: UIViewRepresentable {
7878 // Updates the UIView with new data
7979 func updateUIView( _ mapView: MKMapView , context: Context ) {
8080 // mapView.setCenter(userLocation, animated: true)
81- if isMultiSelectModeEnabled,
82- selectedAnnotations. isEmpty {
83- Task { await manageAnnotations ( mapView, context: context) }
84- }
85- context. coordinator. updateUserRegion ( mapView)
86- context. coordinator. updateVisibleAnnotations ( in: mapView)
87- if context. coordinator. previousAnnotations != items {
88- context. coordinator. previousAnnotations = items
89- Task {
90- await manageAnnotations ( mapView, context: context)
81+ Task {
82+
83+ if context. coordinator. previosMultiSelectionMode != isMultiSelectModeEnabled {
84+ context. coordinator. previosMultiSelectionMode = isMultiSelectModeEnabled
85+ /*Task {*/ await manageAnnotations ( mapView, context: context) /*}*/
86+ }
87+ context. coordinator. updateUserRegion ( mapView)
88+ context. coordinator. updateVisibleAnnotations ( in: mapView)
89+ if context. coordinator. previousAnnotations != items {
90+ context. coordinator. previousAnnotations = items
91+ // Task {
92+ await manageAnnotations ( mapView, context: context)
93+ // }
9194 }
9295 }
9396
9497
98+
9599 // Remove existing overlays
96100 mapView. overlays. forEach { mapView. removeOverlay ( $0) }
97101
@@ -153,6 +157,7 @@ struct CustomMap: UIViewRepresentable {
153157 private var zoomReachedLimit : Bool = false
154158
155159 var previousAnnotations : [ DisplayUnitWithCoordinate ] = [ ]
160+ var previosMultiSelectionMode : Bool = false
156161 private var annotations : [ DisplayUnitAnnotation ] = [ ]
157162 private( set) var clusterManager : ClusterManager = ClusterManager < DisplayUnitAnnotation > ( configuration: . init( maxZoomLevel: 17 , minCountForClustering: 2 , clusterPosition: . nearCenter) )
158163
@@ -529,9 +534,9 @@ struct CustomMap: UIViewRepresentable {
529534
530535 await context. coordinator. clusterManager. removeAll ( )
531536 await context. coordinator. reloadMap ( )
532- let existingCoordinates = mapView. annotations. compactMap {
533- ( $0 as? DisplayUnitAnnotation ) ? . coordinate
534- }
537+ // let existingCoordinates = mapView.annotations.compactMap {
538+ // ($0 as? DisplayUnitAnnotation)?.coordinate
539+ // }
535540
536541 // Check for modals or settings before changing map
537542 if isPresented {
0 commit comments