Cluster pop animation keeps popping when I zoom or move

Đang mở
#415 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@wangela đang làm issue này rồi.

Từ ngày 1/7/2022.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

priority: p2 type: bug

Hi,

I am using the cluster manager in order to display my markers on my map. I wanted to add the pop animation on the appearance of my marker. However every time that I try to move or to zoom on the map, my markers keep re-appearing.
At the beginning, I was just using custom icons on my markers and they kept blinking every time I zoomed or moved on the map. In order to simplify the demonstration, I am just using the pop animation on the appearAnimation of the marker.

First I thought it might been due to the clearItems then to the cluster again so I tried to optimize the renderer a little bit:

func updateCluster(clusterManager: GMUClusterManager, markerItems: [MarkerItem]) {
    var markersToAdd: [POIItem] = []
    var markersToDelete: [POIItem] = []
    for markerItem in markerItems {
        if mapDisplayedItems.contains(where: { $0.id == markerItem.id }) == false {
            let position = CLLocationCoordinate2D(latitude: markerItem.lat, longitude: markerItem.lng)
            let mapItem = POIItem(position: position, id: markerItem.id, picture: nil, markerItem: markerItem)
            markersToAdd = markersToAdd + [mapItem]
        } else if let mapDisplayedItem = mapDisplayedItems.first(where: { $0.id == markerItem.id }), mapDisplayedItem.position.latitude == markerItem.lat && mapDisplayedItem.position.longitude == markerItem.lng {
            mapDisplayedItem.position = CLLocationCoordinate2D(latitude: markerItem.lat, longitude: markerItem.lng)
        }
    }
    for mapDisplayedItem in mapDisplayedItems {
        if markerItems.contains(where: { $0.id == mapDisplayedItem.id }) == false {
            markersToDelete = markersToDelete + [mapDisplayedItem]
        }
    }
    for markerToDelete in markersToDelete {
        mapDisplayedItems = mapDisplayedItems.filter({ $0.id != markerToDelete.id })
        clusterManager.remove(markerToDelete)
    }
    mapDisplayedItems = mapDisplayedItems + markersToAdd
    for markerToAdd in markersToAdd {
        clusterManager.add(markerToAdd)
    }
    if !markersToAdd.isEmpty || !markersToDelete.isEmpty {
        clusterManager.cluster()
    }
}

Then in my renderer method, I tried to optimize it too:

func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
    guard let myItem = marker.userData as? POIItem, var markerItem = myItem.markerItem, !markerItem.hasBeenRendered else {
        return
    }
    marker.appearAnimation = .pop
    markerItem.hasBeenRendered = true
}
Environment details

iOS: 15.4
GoogleMaps: 7.0.0
GooglePlaces: 7.0.0
GoogleUtilities 7.7.0
Google-Maps-iOS-Utils: 4.1.0

Thank you for your help!

Ngôn ngữ chính
Objective-C
Star
775
Fork
444
Merge trung bình
8 giờ 12 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googlemaps/google-maps-ios-utils

Tất cả issue của googlemaps/google-maps-ios-utils

Issue tương tự

Thêm issue về Objective-C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.