summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm29
1 files changed, 29 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index c6c0920f56..24a69e1d5a 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2811,6 +2811,35 @@ public:
return [NSArray arrayWithObjects:&annotations[0] count:annotations.size()];
}
+- (nullable NS_ARRAY_OF(id <MGLAnnotation>) *)visibleAnnotations
+{
+ return [self visibleAnnotationsInRect:self.bounds];
+}
+
+- (nullable NS_ARRAY_OF(id <MGLAnnotation>) *)visibleAnnotationsInRect:(CGRect)rect
+{
+ if (_annotationContextsByAnnotationTag.empty())
+ {
+ return nil;
+ }
+
+ std::vector<MGLAnnotationTag> annotationTags = [self annotationTagsInRect:rect];
+ if (annotationTags.size())
+ {
+ NSMutableArray *annotations = [NSMutableArray arrayWithCapacity:annotationTags.size()];
+
+ for (auto const& annotationTag: annotationTags)
+ {
+ MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag[annotationTag];
+ [annotations addObject:annotationContext.annotation];
+ }
+
+ return [annotations copy];
+ }
+
+ return nil;
+}
+
/// Returns the annotation assigned the given tag. Cheap.
- (id <MGLAnnotation>)annotationWithTag:(MGLAnnotationTag)tag
{