Optimising custom marker image performance with Google Maps SDK for iOS

前端 未结 3 878
深忆病人
深忆病人 2021-01-04 02:43

I have recently been incorporating the Google Maps for iOS SDK within an iOS app. This app is designed to retrieve position of aircraft (including aircraft model, lat/lng, s

3条回答
  •  抹茶落季
    2021-01-04 03:12

    Instead of setting marker's iconView, set marker's icon. That too initialize the image outside of for loop, as below
    
    func displayMarkers() {
    let iconImage = UIImage(named: "locationgreen")
    for partner in partners {
        let lat : Double = Double(partner.location?.coordinates![1] ?? 0)
        let lng : Double = Double(partner.location?.coordinates![0] ?? 0)
    
        let position = CLLocationCoordinate2D(latitude: lat, longitude: lng)
        let marker = GMSMarker(position: position)
        marker.title = partner.name
        marker.icon = iconImage
        }
    }
    

提交回复
热议问题