Adding Click Event on InfoWindow/Marker in Google Maps SDK for native iOS/objective C
1.conform to the GMSMapViewDelegate
protocol.
@interface YourViewController () <GMSMapViewDelegate>
// your properties
@end
2.set your mapView_
delegate.
mapView_.delegate = self;
3.implement the GMSMapViewDelegate
method
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
// your code
}
btw, marker.userData
is useful. you can set your needed data into it and use it in - mapView:didTapInfoWindowOfMarker:
where you adding Map,add
mapView_.delegate=self;
then use this
-(void)mapView:(GMSMapView *)mapView
didTapInfoWindowOfMarker:(id<GMSMarker>)marker{
//info window tapped
}
a full answer for swift 4
add
GMSMapViewDelegate
as delegateset yourmap delegate like this :
googlemap.delegate = self
add this func
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool { // do something return true }