summaryrefslogtreecommitdiff
path: root/platform/macos/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r--platform/macos/src/MGLMapView.mm21
1 files changed, 15 insertions, 6 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 5d14192c61..68a21b5666 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1806,12 +1806,18 @@ public:
for (auto const& annotationTag: annotationTags)
{
- if (!_annotationContextsByAnnotationTag.count(annotationTag))
+ if (!_annotationContextsByAnnotationTag.count(annotationTag) ||
+ annotationTag == MGLAnnotationTagNotFound)
{
continue;
}
+
MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
- [annotations addObject:annotationContext.annotation];
+ NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag);
+ if (annotationContext.annotation)
+ {
+ [annotations addObject:annotationContext.annotation];
+ }
}
return [annotations copy];
@@ -1822,11 +1828,12 @@ public:
/// Returns the annotation assigned the given tag. Cheap.
- (id <MGLAnnotation>)annotationWithTag:(MGLAnnotationTag)tag {
- if (!_annotationContextsByAnnotationTag.count(tag)) {
+ if ( ! _annotationContextsByAnnotationTag.count(tag) ||
+ tag == MGLAnnotationTagNotFound) {
return nil;
}
- MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag[tag];
+ MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);
return annotationContext.annotation;
}
@@ -2063,8 +2070,8 @@ public:
// Filter out any annotation whose image is unselectable or for which
// hit testing fails.
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];
+ NSAssert(annotation, @"Unknown annotation found nearby click");
if (!annotation) {
return true;
}
@@ -2153,9 +2160,11 @@ public:
}
- (id <MGLAnnotation>)selectedAnnotation {
- if (!_annotationContextsByAnnotationTag.count(_selectedAnnotationTag)) {
+ if ( ! _annotationContextsByAnnotationTag.count(_selectedAnnotationTag) ||
+ _selectedAnnotationTag == MGLAnnotationTagNotFound) {
return nil;
}
+
MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(_selectedAnnotationTag);
return annotationContext.annotation;
}