From cc47da5a15650c3f8ede9f7e253e4099dc61673f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 24 Jan 2016 23:19:15 -0800 Subject: [ios] Allow removing never-added annotations https://github.com/mapbox/mapbox-gl-native/issues/3159#issuecomment-174422048 --- platform/ios/src/MGLMapView.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'platform/ios/src/MGLMapView.mm') 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 )overlay -- cgit v1.2.1