diff options
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.h | 9 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 16 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.h | 9 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 16 |
6 files changed, 52 insertions, 0 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e8de9e3723..ceb371118d 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## master * The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. +* Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) ## 3.6.0 diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 8d26b1c90e..ca765a046b 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 + empty array. + */ +@property (nonatomic, readonly, nonnull) 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..d97c0b6602 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3531,6 +3531,22 @@ public: } } +- (nonnull NS_ARRAY_OF(id <MGLOverlay>) *)overlays +{ + if (self.annotations == nil) { return @[]; } + + NS_MUTABLE_ARRAY_OF(id <MGLOverlay>) *mutableOverlays = [NSMutableArray array]; + + [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 ]]; diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 377c321452..579624f0e6 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -3,6 +3,7 @@ ## master * The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. +* Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) ## 0.5.0 diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index fb715a506d..6bfdcfd100 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -730,6 +730,15 @@ MGL_EXPORT 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 + empty array. + */ +@property (nonatomic, readonly, nonnull) NS_ARRAY_OF(id <MGLOverlay>) *overlays; + +/** Adds a single overlay to the map. To remove an overlay from a map, use the `-removeOverlay:` method. diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 59951f946d..98958f045d 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2413,6 +2413,22 @@ public: #pragma mark Overlays +- (nonnull NS_ARRAY_OF(id <MGLOverlay>) *)overlays +{ + if (self.annotations == nil) { return @[]; } + + NS_MUTABLE_ARRAY_OF(id <MGLOverlay>) *mutableOverlays = [NSMutableArray array]; + + [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]]; } |