mapView didTapInfoWindowOfMarker method does not work? Google Maps iOS SDK

江枫思渺然 提交于 2019-12-11 09:16:09

问题


Anyone else experiencing this? I'm using the latest Google Maps SDK for iOS. This is what I have in the didTapInfoWindowOfMarker method :

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

Not getting any response in my output.


回答1:


Sounds like you didn't add delegate and protocol for your GMSMapView object, something like:

mapView_.delegate = self;

in loadView method.

So, the full - (void)loadViewand delegate method should be:

@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.
}


来源:https://stackoverflow.com/questions/15125158/mapview-didtapinfowindowofmarker-method-does-not-work-google-maps-ios-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!