Search code examples
iosgoogle-mapsgoogle-maps-sdk-ios

SDWebImage not working in Google Maps InfoWindow


i'm trying to load an image placed in InfoWindow via SDWebImage.

On first opening of this InfoWindow mainLogoImageView placing only placeholder. On second - loaded image. The problem is that image can't load on first opening of InfoWindow(it's not depends on how much time i'm waiting for loading image)

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! { 

var infoWindow : CustomInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as CustomInfoWindow

infoWindow.mainLogoImageView.sd_setImageWithURL(NSURL(string: self.sharedManager.myModel[0].img_logo), placeholderImage: UIImage(named: "logo_placeholder.png"))

return infoWindow

}

Thanks for helping


Solution

  • insert marker.tracksInfoWindowChanges = true; in mapView function

    Answer to your question

    func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) UIView! {   
       marker.tracksInfoWindowChanges = true;
       var infoWindow : CustomInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as CustomInfoWindow
       infoWindow.mainLogoImageView.sd_setImageWithURL(NSURL(string: self.sharedManager.myModel[0].img_logo), placeholderImage: UIImage(named: "logo_placeholder.png"))
    
       return infoWindow
    }