【问题标题】:GMSMarker custom infoWindow doesn't shownGMSMarker 自定义信息窗口未显示
【发布时间】:2016-03-09 13:16:39
【问题描述】:

我已经在我的应用程序上实现了-mapView: markerInfoWindow:,直到现在一切正常,但昨天我已经将 Google Maps iOS SDK 更新到最新版本 (1.12.23211.0),从那时起信息窗口就没有了并显示默认信息窗口(带标题的白色条)。

我尝试重新安装最新版本的 SDK(使用 Cocoa pod),但仍然无法正常工作(未显示我的自定义信息窗口)。

谁能帮我解决这个问题?

我的代码:

我的VC

-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
{
    //Creating "infoWindow"(infoWindow) and setting it with nib file called "infoWindow"
    infoWindow *infoWindow=[[[NSBundle mainBundle] loadNibNamed:@"infoWindow" owner:self options:nil] firstObject];
    //Setting "infoWindow"(infoWindow)'s storeNameLabel's text to "marker"(customMarker)'s title
    infoWindow.storeNameLabel.text=((customMarker*)marker).title;

    //Creating "fullAddress"(NSString) ands setting it to "marker"(customMarker)'s address
    NSString *fullAddress = ((customMarker*)marker).address;
    //Creating "addressArray"(NSArray) and adding it "address" without the city name (until the "," char)
    NSArray *addressArray = [fullAddress componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];

    //Setting "infoWindow"(infoWindow)'s storeAddressLabel's text to "addressArray"(NSArray) first object
    infoWindow.storeAddressLabel.text=[addressArray firstObject];

    //Returning "infoWindow"(infoWindow)
    return infoWindow;
}
-(void)createMarkerWithStore:(Store*)store
{
   dispatch_async(dispatch_get_main_queue(), ^{
       customMarker *marker=[[customMarker alloc] initWithPosition:store.geoPoint andTitle:store.storeName andAddress:store.address andIcon:store.category.markerIcon];
       marker.map=self.mapView;
       store.marker=marker;
   });
}

customMarker

-(void)awakeFromNib
{
    self.storeNameLabel.adjustsFontSizeToFitWidth=YES;
    self.storeAddressLabel.adjustsFontSizeToFitWidth=YES;
}

customMarker

-(instancetype)initWithPosition:(CLLocationCoordinate2D)position andTitle:(NSString*)title andAddress:(NSString*)address andIcon:(UIImage*)icon
{
    self=[super init];
    if (self) {
        self.position=position;
        self.title=title;
        self.address=address;
        self.icon=icon;
        self.flat=YES;
        self.appearAnimation=kGMSMarkerAnimationPop;
    }
    return self;
}

非常感谢!

【问题讨论】:

    标签: ios objective-c iphone cocoa-touch google-maps-sdk-ios


    【解决方案1】:

    问题是我忘记将代理设置为地图

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      • 2014-03-14
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      相关资源
      最近更新 更多