diff options
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 18 | ||||
-rw-r--r-- | platform/ios/src/MGLUserLocationAnnotationView.h | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLUserLocationAnnotationView.m | 6 |
3 files changed, 18 insertions, 7 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 4ec3619189..f204940469 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1392,17 +1392,21 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) return; } - CGPoint tapPoint = [singleTap locationInView:self]; - - CALayer *hitLayer = self.userLocationVisible ? [self.userLocationAnnotationView.layer.presentationLayer hitTest:tapPoint] : nil; - if (hitLayer && hitLayer != self.userLocationAnnotationView.haloLayer.presentationLayer) + if (self.userLocationVisible) { - if ( ! _userLocationAnnotationIsSelected) + CGPoint tapPointForUserLocation = [singleTap locationInView:self.userLocationAnnotationView]; + CALayer *hitLayer = [self.userLocationAnnotationView.hitTestLayer hitTest:tapPointForUserLocation]; + if (hitLayer) { - [self selectAnnotation:self.userLocation animated:YES]; + if ( ! _userLocationAnnotationIsSelected) + { + [self selectAnnotation:self.userLocation animated:YES]; + } + return; } - return; } + + CGPoint tapPoint = [singleTap locationInView:self]; MGLAnnotationTag hitAnnotationTag = [self annotationTagAtPoint:tapPoint persistingResults:YES]; if (hitAnnotationTag != MGLAnnotationTagNotFound) diff --git a/platform/ios/src/MGLUserLocationAnnotationView.h b/platform/ios/src/MGLUserLocationAnnotationView.h index 1eb50b7740..8ab9ea6e79 100644 --- a/platform/ios/src/MGLUserLocationAnnotationView.h +++ b/platform/ios/src/MGLUserLocationAnnotationView.h @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) MGLMapView *mapView; @property (nonatomic) MGLUserLocation *annotation; @property (nonatomic, readonly, nullable) CALayer *haloLayer; +@property (nonatomic, readonly) CALayer *hitTestLayer; - (instancetype)initInMapView:(MGLMapView *)mapView NS_DESIGNATED_INITIALIZER; - (void)setupLayers; diff --git a/platform/ios/src/MGLUserLocationAnnotationView.m b/platform/ios/src/MGLUserLocationAnnotationView.m index c514026e42..3ab2c5a796 100644 --- a/platform/ios/src/MGLUserLocationAnnotationView.m +++ b/platform/ios/src/MGLUserLocationAnnotationView.m @@ -147,6 +147,12 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck } } +- (CALayer *)hitTestLayer +{ + // only the main dot should be interactive (i.e., exclude the accuracy ring and halo) + return _dotBorderLayer ?: _puckDot; +} + - (void)setupLayers { if (CLLocationCoordinate2DIsValid(self.annotation.coordinate)) |