diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-02-10 22:02:40 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-02-10 22:02:46 -0800 |
commit | 51d7d204dbed99ffec67002c6e27cce7f33d4077 (patch) | |
tree | 8ea1dbbae851658d4f9d18f2ef0b41ac406ebf24 /platform/osx | |
parent | bd59ab9a5285bf56ecc7a02e180a21f269ad68c0 (diff) | |
download | qtlocation-mapboxgl-51d7d204dbed99ffec67002c6e27cce7f33d4077.tar.gz |
[ios, osx] Exclude misses from nearby annotations
After filtering out elements of a vector using std::remove_if(), it’s apparently necessary to resize the vector. Otherwise, removing only has the effect of shifting the non-matching items to the end of the vector. This change reduces the annotation tap target back to almost what it was before #3261, except that these days the target is centered around the annotation image rather than the center point. There remains a much smaller slop area around the annotation, but nothing close to the effective padding before this change.
Fixes #3880.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 73cbb7fe80..ca282facdb 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -1717,7 +1717,7 @@ public: // Filter out any annotation whose image is unselectable or for which // hit testing fails. - std::remove_if(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MGLAnnotationTag annotationTag) { + auto end = std::remove_if(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MGLAnnotationTag annotationTag) { NSAssert(_annotationContextsByAnnotationTag.count(annotationTag) != 0, @"Unknown annotation found nearby click"); id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag]; if (!annotation) { @@ -1736,6 +1736,7 @@ public: return !!![annotationImage.image hitTestRect:hitRect withImageDestinationRect:annotationRect context:nil hints:nil flipped:NO]; }); + nearbyAnnotations.resize(std::distance(nearbyAnnotations.begin(), end)); } MGLAnnotationTag hitAnnotationTag = MGLAnnotationTagNotFound; |