diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index 713d577f2..ea0809545 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -570,6 +570,12 @@ IB_DESIGNABLE /** @name Managing Annotations */ +/* Tells the delegate that the user tapped on the callout view itself. + * + * @param mapView The map view containing the specified annotation. + * @param annotation The annotation whose button was tapped.*/ +- (void)mapView:(MGLMapView *)mapView tapOnLabelForAnnotation:(id )annotation; + /** Tells the delegate that the user tapped one of the annotation's accessory buttons. * * Accessory views contain custom content and are positioned on either side of the annotation title text. If a view you specify is a descendant of the `UIControl` class, the map view calls this method as a convenience whenever the user taps your view. You can use this method to respond to taps and perform any actions associated with that control. For example, if your control displayed additional information about the annotation, you could use this method to present a modal panel with that information. diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 64f8d0f69..85edc33dc 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -79,7 +79,7 @@ mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction #pragma mark - Private - -@interface MGLMapView () +@interface MGLMapView () @property (nonatomic) EAGLContext *context; @property (nonatomic) GLKView *glView; @@ -1451,6 +1451,14 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) } } +- (void)calloutViewClicked:(SMCalloutView *__attribute__ ((unused)))calloutView +{ + if ([self.delegate respondsToSelector:@selector(mapView:tapOnLabelForAnnotation:)]) + { + [self.delegate mapView:self tapOnLabelForAnnotation:self.selectedAnnotation]; + } +} + - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { NSArray *validSimultaneousGestures = @[ self.pan, self.pinch, self.rotate ]; @@ -2445,7 +2453,10 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) [self.selectedAnnotationCalloutView.rightAccessoryView addGestureRecognizer:calloutAccessoryTap]; } } - + + // set annotation delegate to handle taps on the callout view + self.selectedAnnotationCalloutView.delegate = self; + // present popup [self.selectedAnnotationCalloutView presentCalloutFromRect:calloutBounds inView:self.glView