ios - 在 iOS 中使用 Google map 时如何使用自定义标注进行注释?

标签 ios objective-c google-maps uiview

我正在 iOS 应用程序 中使用 Google map 。到目前为止,我能够在 map 上显示用户位置。我试图在单击注释时使用自定义标注。

这是我到目前为止所做的。

1] 创建一个 XIB 文件并为其分配一个 UIView 子类的类名。

2]使用markerInfoWindow委托(delegate)方法如下。

- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
{
    CustomGoogleCallOut *view =  [[[NSBundle mainBundle]loadNibNamed:@"CustomGoogleCallOut" owner:self options:nil]objectAtIndex:0];
    view.callOutImageView.image = [UIImage imageNamed:@"avatar.png"];
    view.callOutTitleLabel .text = @"title";
    view.callOutUserName.text = @"Mario";
    return view;
}

但是我看不到调用。我在这里错过了什么?

最佳答案

您缺少代表。在 h 文件中

: UIViewController<GMSMapViewDelegate>

在.m 文件中

mapView.delegate = self;

关于ios - 在 iOS 中使用 Google map 时如何使用自定义标注进行注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20921054/

相关文章:

Android 谷歌地图多边形点击事件

ios - 根据键数组过滤NSDictionary

ios - 隐藏 Firebase 崩溃报告

ios - iOS 应用教程中的相机

ios - AVSpeechUtterance 静音模式下的发音

ios - 为什么图像未显示在 Objective-C 的 cellforRowAtIndexPath 中

ios 在 Swift 中将 void* 传递给 UISaveVideoAtPathToSavedPhotosAlbum

javascript - 如何在 Google Maps InfoWindow 中创建 CSS 样式的 dom 元素?

ios - 分享 MKMapView 截图

javascript - 无法通过谷歌javascript map api获取 map ,不会抛出错误,但iframe src约为:blank