mapView didTapInfoWindowOfMarker方法不起作用? Google Maps iOS SDK

时间:2013-02-28 00:16:15

标签: google-maps-sdk-ios

其他人遇到此事吗?我正在使用最新的Google Maps SDK for iOS。这就是我在didTapInfoWindowOfMarker方法中所拥有的:

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker {
  NSLog(@"yes");
}

我的输出中没有得到任何回复。

1 个答案:

答案 0 :(得分:5)

听起来你没有为你的GMSMapView对象添加委托和协议,例如:

mapView_.delegate = self;
在loadView方法中

因此,完整的- (void)loadView和委托方法应为:

@interface ViewController () <GMSMapViewDelegate> // Add this if you haven't
{
    id<GMSMarker> myMarker;
}


- (void)loadView {
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                          longitude:151.2086
                                                               zoom:6];
  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  mapView_.myLocationEnabled = YES;
  mapView_.delegate = self; // This sets the delegate for map view
  self.view = mapView_;
}

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker {
  NSLog(@"yes"); // And now this should work.
}