summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEimantas Vaiciunas <eimantas@walkingsmarts.com>2017-04-02 15:05:22 +0300
committerMinh Nguyễn <mxn@1ec5.org>2017-05-20 19:55:03 -0700
commitb76ecfa657af4b36fe5658e0875d1fc492ed9230 (patch)
tree3be813ace7f45f4f97dd1c50c93724bde02d849b
parent1f921299b0fc43c04cf0d16138d642a5d4e70930 (diff)
downloadqtlocation-mapboxgl-b76ecfa657af4b36fe5658e0875d1fc492ed9230.tar.gz
Add `overlays` property to `MGLMapView.mm`
Implemented by filtering the `annotations` property for annotations that conform to `MGLOverlay` protocol.
-rw-r--r--platform/macos/src/MGLMapView.h2
-rw-r--r--platform/macos/src/MGLMapView.mm12
2 files changed, 14 insertions, 0 deletions
diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h
index fb715a506d..eb37f0540d 100644
--- a/platform/macos/src/MGLMapView.h
+++ b/platform/macos/src/MGLMapView.h
@@ -729,6 +729,8 @@ MGL_EXPORT IB_DESIGNABLE
#pragma mark Overlaying the Map
+@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLOverlay>) *overlays;
+
/**
Adds a single overlay to the map.
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 59951f946d..db459f6a2f 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -2413,6 +2413,18 @@ public:
#pragma mark Overlays
+- (nullable NS_ARRAY_OF(id <MGLOverlay>) *)overlays {
+ NS_MUTABLE_ARRAY_OF(id <MGLOverlay>) *mutableOverlays = [NSMutableArray new];
+
+ [self.annotations enumerateObjectsUsingBlock:^(id<MGLAnnotation> _Nonnull annotation, NSUInteger idx, BOOL * _Nonnull stop) {
+ if ([annotation conformsToProtocol:@protocol(MGLOverlay)]) {
+ [mutableOverlays addObject:(id<MGLOverlay>)annotation];
+ }
+ }];
+
+ return [NSArray arrayWithArray:mutableOverlays];
+}
+
- (void)addOverlay:(id <MGLOverlay>)overlay {
[self addOverlays:@[overlay]];
}