如何在Google Maps iOS SDK中强制刷新markerInfoWindow的内容 [英] How to force refresh contents of the markerInfoWindow in Google Maps iOS SDK

查看:138
本文介绍了如何在Google Maps iOS SDK中强制刷新markerInfoWindow的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要返回UIImageView in - (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker;

UIImageView使用SDWebImage通过URL动态加载图像.

This UIImageView loads images dynamically through a URL using SDWebImage.

如文档所述,有关标记信息窗口:

As the documentation says about marker info windows:

注意:信息窗口每次在地图上显示时都将被渲染为图像.这意味着在激活状态下对其属性所做的任何更改都不会立即可见.信息窗口的内容将在下次显示时刷新.

Note: The info window is rendered as an image each time it is displayed on the map. This means that any changes to its properties while it is active will not be immediately visible. The contents of the info window will be refreshed the next time that it is displayed.

重点是,下载图像后,信息窗口不会刷新,并一直显示占位符图像,直到用户隐藏然后再次显示.

The point is that after downloading the image the info window doesn't refresh and keep showing the placeholder image until user hides then show it back again..

因此,我需要在下载的图像块中强制刷新markerInfoWindow的内容.

So I need to force refresh the contents of the markerInfoWindow in the block of image downloaded..

推荐答案

这是我使用以下解决方法解决的问题:

This is how I fixed the problem using the workaround bellow:

UIImage *img = [[SDWebImageManager sharedManager] imageWithURL:[NSURL URLWithString:Img_URL]]; //Img_URL is NSString of your image URL
    if (img) {       //If image is previously downloaded set it and we're done.
        [imageView setImage:img];
    }else{
        [imageView setImageWithURL:[NSURL URLWithString:Img_URL] placeholderImage:[UIImage imageNamed:@"defaultPin"] success:^(UIImage *image, BOOL cached) {
            if (!marker.snippet || !cached) {
                [marker setSnippet:@""];                 //Set a flag to prevent an infinite loop
                if (mapView.selectedMarker == marker) {  //Only set if the selected marker equals to the downloaded marker
                    [mpVu setSelectedMarker:marker];
                }
            }
        } failure:^(NSError *error) {

        }];
    }

这篇关于如何在Google Maps iOS SDK中强制刷新markerInfoWindow的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆