summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-01-24 23:19:15 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-01-24 23:19:15 -0800
commitcc47da5a15650c3f8ede9f7e253e4099dc61673f (patch)
treed428f05e19617052e9847b74e1c99520563e6f13
parent759b207bf1e0c32e240ad93ac13d4518084e74f1 (diff)
downloadqtlocation-mapboxgl-cc47da5a15650c3f8ede9f7e253e4099dc61673f.tar.gz
[ios] Allow removing never-added annotations
https://github.com/mapbox/mapbox-gl-native/issues/3159#issuecomment-174422048
-rw-r--r--platform/ios/src/MGLMapView.mm14
1 files changed, 10 insertions, 4 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index be0d98ee2c..5447a10304 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2443,7 +2443,10 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation");
MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation];
- NSAssert(annotationTag != MGLAnnotationTagNotFound, @"No ID for annotation %@", annotation);
+ if (annotationTag == MGLAnnotationTagNotFound)
+ {
+ continue;
+ }
annotationTagsToRemove.push_back(annotationTag);
if (annotationTag == _selectedAnnotationTag)
@@ -2454,9 +2457,12 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
_annotationContextsByAnnotationTag.erase(annotationTag);
}
- [self willChangeValueForKey:@"annotations"];
- _mbglMap->removeAnnotations(annotationTagsToRemove);
- [self didChangeValueForKey:@"annotations"];
+ if ( ! annotationTagsToRemove.empty())
+ {
+ [self willChangeValueForKey:@"annotations"];
+ _mbglMap->removeAnnotations(annotationTagsToRemove);
+ [self didChangeValueForKey:@"annotations"];
+ }
}
- (void)addOverlay:(id <MGLOverlay>)overlay