我已经在我的应用程序上实现了-mapView: markerInfoWindow:
,直到现在一切都运行良好,但昨天我已将Google Maps iOS SDK更新到最新版本(1.12.23211.0),从那时起信息窗口就没了显示并显示默认信息窗口(带标题的白色条)。
我尝试重新安装最新版本的SDK(使用Cocoa pod),但它仍然无法正常工作(我的自定义信息窗口未显示)。
任何人都可以帮我解决这个问题吗?
我的代码:
myVC :
-(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;
}
非常感谢!
答案 0 :(得分:0)
问题是我忘了将委托设置为地图