summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEimantas Vaiciunas <eimantas@walkingsmarts.com>2017-04-02 15:14:00 +0300
committerMinh Nguyễn <mxn@1ec5.org>2017-05-20 19:55:04 -0700
commit021833b82ab16676bf62b62e5415574f71181efb (patch)
treef622379cf045f57ea0353dd74a3d7558a4311394
parente1c7ab618e8125f9cf63fb5a1fa95c1e188ccee0 (diff)
downloadqtlocation-mapboxgl-021833b82ab16676bf62b62e5415574f71181efb.tar.gz
Add `overlays` property to iOS sdk
Implementation is identical to the one in macOS SDK.
-rw-r--r--platform/ios/src/MGLMapView.h9
-rw-r--r--platform/ios/src/MGLMapView.mm14
2 files changed, 23 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 8d26b1c90e..93fd681e39 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -1131,6 +1131,15 @@ IB_DESIGNABLE
#pragma mark Overlaying the Map
/**
+ The complete list of overlays associated with the receiver. (read-only)
+
+ The objects in this array must adopt the `MGLOverlay` protocol. If no
+ overlays are associated with the map view, the value of this property is
+ `nil`.
+ */
+@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLOverlay>) *overlays;
+
+/**
Adds a single overlay object to the map.
To remove an overlay from a map, use the `-removeOverlay:` method.
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 8cba1187ea..c1d6ad0217 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3531,6 +3531,20 @@ public:
}
}
+- (nullable NS_ARRAY_OF(id <MGLOverlay>) *)overlays {
+ if (self.annotations == nil) { return nil; }
+
+ 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 ]];