From ae88c01c9455654038341eee5baaaece71796b35 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sat, 6 Aug 2016 17:59:35 -0700 Subject: [PATCH 1/2] [ios] Hit test the user location annotation dot specifically Rather than try to exclude layers in the touch hit test, this specifically only checks against the main layer for the user dot or puck. Back-port of e4a9173a2a5c585dda3fa7a0f955cff1552f8d25. --- platform/ios/src/MGLMapView.mm | 18 +++++++++++------- .../ios/src/MGLUserLocationAnnotationView.h | 1 + .../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 4ec361918..f20494046 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 1eb50b774..8ab9ea6e7 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 c514026e4..3ab2c5a79 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)) From c64a0c24866b9d199153a1fe65c455d5807b50a6 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 8 Aug 2016 15:25:20 -0400 Subject: [PATCH 2/2] ios-v3.3.4 Bump version number and update changelog. --- platform/ios/CHANGELOG.md | 6 +++++- platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 1b90d2099..43ccc9c0d 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog for Mapbox iOS SDK -Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. + +## 3.3.4 + +* Fixed an issue that caused the user dot to be selected when tapping an annotation that lies within the user dot’s accuracy circle. First attempt was [#5816](https://github.com/mapbox/mapbox-gl-native/pull/5816) in v3.3.2, which excluded the pulsing halo but not the accuracy circle. ([#5894](https://github.com/mapbox/mapbox-gl-native/pull/5894)) ## 3.3.3 diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index cfcc54d32..35c394f39 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '3.3.3-symbols' + m.version = '3.3.4-symbols' m.summary = 'Open source vector map solution for iOS with full styling capabilities.' m.description = 'Open source, OpenGL-based vector map solution for iOS with full styling capabilities and Cocoa Touch APIs.' diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index a315085f3..69704e8f3 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |m| m.name = 'Mapbox-iOS-SDK' - m.version = '3.3.3' + m.version = '3.3.4' m.summary = 'Open source vector map solution for iOS with full styling capabilities.' m.description = 'Open source, OpenGL-based vector map solution for iOS with full styling capabilities and Cocoa Touch APIs.'