summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--platform/ios/MGLMapView.mm17
2 files changed, 15 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f912bd0091..64794924a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,8 @@ Known issues:
## iOS master
- `MGLMapView` methods that alter the viewport now accept optional completion handlers. ([#3090](https://github.com/mapbox/mapbox-gl-native/pull/3090))
+- Tapping now selects annotations more reliably. Tapping near the top of a large annotation image now selects that annotation. An annotation image’s alignment insets influence how far away the user can tap and still select the annotation. For example, if your annotation image has a large shadow, you can keep that shadow from being tappable by excluding it from the image’s alignment rect. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261))
+- The user dot’s callout view is now centered above the user dot. It was previously offset slightly to the left. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261))
## iOS 3.0.1
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 560e5249d5..092750cc16 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -2370,10 +2370,6 @@ std::chrono::steady_clock::duration durationInSeconds(float duration)
return self.annotationImagesByIdentifier[identifier];
}
-CLLocationDistance MGLDistanceBetweenCoordinate2Ds(CLLocationCoordinate2D a, CLLocationCoordinate2D b) {
- return hypot(b.latitude - a.latitude, b.longitude - a.longitude);
-}
-
/**
Returns the tag of the annotation at the given point in the view.
@@ -2435,6 +2431,19 @@ CLLocationDistance MGLDistanceBetweenCoordinate2Ds(CLLocationCoordinate2D a, CLL
if (nearbyAnnotations == _annotationsNearbyLastTap)
{
+ // The first selection in the cycle should be the one nearest to the
+ // tap.
+ CLLocationCoordinate2D currentCoordinate = [self convertPoint:point toCoordinateFromView:self];
+ std::sort(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MGLAnnotationTag tagA, const MGLAnnotationTag tagB) {
+ CLLocationCoordinate2D coordinateA = [[self annotationWithTag:tagA] coordinate];
+ CLLocationCoordinate2D coordinateB = [[self annotationWithTag:tagB] coordinate];
+ CLLocationDegrees deltaA = hypot(coordinateA.latitude - currentCoordinate.latitude,
+ coordinateA.longitude - currentCoordinate.longitude);
+ CLLocationDegrees deltaB = hypot(coordinateB.latitude - currentCoordinate.latitude,
+ coordinateB.longitude - currentCoordinate.longitude);
+ return deltaA < deltaB;
+ });
+
// The last time we persisted a set of annotations, we had the same
// set of annotations as we do now. Cycle through them.
if (_selectedAnnotationTag == MGLAnnotationTagNotFound