iOS 的自定义 Google 地图标记 (GMSMarker)
Custom Google Maps Marker for iOS (GMSMarker)
我正在尝试为 Google 地图创建一个自定义标记,但我的代码给我一个带有 space 的奇怪视图,如下图所示:
那个白色的景色是什么?如何删除它?应该只有红色的!
-(UIView *)mapView:(GMSMapView *)mapView markerInfoContents:(GMSMarker *)marker{
UIView *infoView = [UIView new];
infoView.frame = CGRectMake(0, 0, 290, 192);
// Setting the bg as red just to illustrate
infoView.backgroundColor = [UIColor redColor];
return infoView;
}
我可能有点生疏,但这不是错误的功能吗?
有一个 markerInfoWindow 和一个 markerInfoContents(您正在使用)。
window 是全部,而内容是一个视图,它将放置在默认信息 window 框架中
看看here
出现这种白色背景的原因是您使用了错误的委托方法。用这个替换你的代码:
-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{
UIView *infoView = [UIView new];
infoView.frame = CGRectMake(0, 0, 290, 192);
// Setting the bg as red just to illustrate
infoView.backgroundColor = [UIColor redColor];
return infoView;
}
我正在尝试为 Google 地图创建一个自定义标记,但我的代码给我一个带有 space 的奇怪视图,如下图所示:
那个白色的景色是什么?如何删除它?应该只有红色的!
-(UIView *)mapView:(GMSMapView *)mapView markerInfoContents:(GMSMarker *)marker{
UIView *infoView = [UIView new];
infoView.frame = CGRectMake(0, 0, 290, 192);
// Setting the bg as red just to illustrate
infoView.backgroundColor = [UIColor redColor];
return infoView;
}
我可能有点生疏,但这不是错误的功能吗?
有一个 markerInfoWindow 和一个 markerInfoContents(您正在使用)。 window 是全部,而内容是一个视图,它将放置在默认信息 window 框架中
看看here
出现这种白色背景的原因是您使用了错误的委托方法。用这个替换你的代码:
-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{
UIView *infoView = [UIView new];
infoView.frame = CGRectMake(0, 0, 290, 192);
// Setting the bg as red just to illustrate
infoView.backgroundColor = [UIColor redColor];
return infoView;
}