Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.0-beta.2-master
This commit is contained in:
@@ -568,6 +568,16 @@ IB_DESIGNABLE
|
||||
*/
|
||||
- (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations;
|
||||
|
||||
/**
|
||||
The complete list of annotations associated with the receiver that are
|
||||
currently visible.
|
||||
|
||||
The objects in this array must adopt the `MGLAnnotation` protocol. If no
|
||||
annotations are associated with the map view or if no annotations associated
|
||||
with the map view are currently visible, the value of this property is `nil`.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLAnnotation>) *visibleAnnotations;
|
||||
|
||||
/**
|
||||
Removes an annotation from the map view, deselecting it if it is selected.
|
||||
|
||||
@@ -608,6 +618,17 @@ IB_DESIGNABLE
|
||||
*/
|
||||
- (nullable MGLAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier;
|
||||
|
||||
/**
|
||||
Returns the list of annotations associated with the receiver that intersect with
|
||||
the given rectangle.
|
||||
|
||||
@param rect A rectangle expressed in the map view’s coordinate system.
|
||||
@return An array of objects that adopt the `MGLAnnotation` protocol or `nil` if
|
||||
no annotations associated with the map view are currently visible in the
|
||||
rectangle.
|
||||
*/
|
||||
- (nullable NS_ARRAY_OF(id <MGLAnnotation>) *)visibleAnnotationsInRect:(CGRect)rect;
|
||||
|
||||
#pragma mark Managing Annotation Selections
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,7 +108,7 @@ enum { MGLAnnotationTagNotFound = UINT32_MAX };
|
||||
|
||||
/// Mapping from an annotation tag to metadata about that annotation, including
|
||||
/// the annotation itself.
|
||||
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap;
|
||||
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationTagContextMap;
|
||||
|
||||
/// Returns an NSImage for the default marker image.
|
||||
NSImage *MGLDefaultMarkerImage() {
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
CGFloat _pitchAtBeginningOfGesture;
|
||||
BOOL _didHideCursorDuringGesture;
|
||||
|
||||
MGLAnnotationContextMap _annotationContextsByAnnotationTag;
|
||||
MGLAnnotationTagContextMap _annotationContextsByAnnotationTag;
|
||||
MGLAnnotationTag _selectedAnnotationTag;
|
||||
MGLAnnotationTag _lastSelectedAnnotationTag;
|
||||
/// Size of the rectangle formed by unioning the maximum slop area around every annotation image.
|
||||
@@ -1623,6 +1623,35 @@ public:
|
||||
return [NSArray arrayWithObjects:&annotations[0] count:annotations.size()];
|
||||
}
|
||||
|
||||
- (nullable NS_ARRAY_OF(id <MGLAnnotation>) *)visibleAnnotations
|
||||
{
|
||||
return [self visibleFeaturesInRect: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 {
|
||||
if (!_annotationContextsByAnnotationTag.count(tag)) {
|
||||
@@ -1666,12 +1695,6 @@ public:
|
||||
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"Annotation does not conform to MGLAnnotation");
|
||||
|
||||
if ([annotation isKindOfClass:[MGLMultiPoint class]]) {
|
||||
// Actual multipoints aren’t supported as annotations.
|
||||
if ([annotation isMemberOfClass:[MGLMultiPoint class]]
|
||||
|| [annotation isMemberOfClass:[MGLMultiPointFeature class]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The multipoint knows how to style itself (with the map view’s help).
|
||||
MGLMultiPoint *multiPoint = (MGLMultiPoint *)annotation;
|
||||
if (!multiPoint.pointCount) {
|
||||
@@ -1685,8 +1708,9 @@ public:
|
||||
|
||||
[(NSObject *)annotation addObserver:self forKeyPath:@"coordinates" options:0 context:(void *)(NSUInteger)annotationTag];
|
||||
} else if (![annotation isKindOfClass:[MGLMultiPolyline class]]
|
||||
|| ![annotation isKindOfClass:[MGLMultiPolygon class]]
|
||||
|| ![annotation isKindOfClass:[MGLShapeCollection class]]) {
|
||||
&& ![annotation isKindOfClass:[MGLMultiPolygon class]]
|
||||
&& ![annotation isKindOfClass:[MGLShapeCollection class]]
|
||||
&& ![annotation isKindOfClass:[MGLPointCollection class]]) {
|
||||
MGLAnnotationImage *annotationImage = nil;
|
||||
if (delegateHasImagesForAnnotations) {
|
||||
annotationImage = [self.delegate mapView:self imageForAnnotation:annotation];
|
||||
|
||||
@@ -24,6 +24,7 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
|
||||
#import "MGLOfflineStorage.h"
|
||||
#import "MGLOverlay.h"
|
||||
#import "MGLPointAnnotation.h"
|
||||
#import "MGLPointCollection.h"
|
||||
#import "MGLPolygon.h"
|
||||
#import "MGLPolyline.h"
|
||||
#import "MGLShape.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
+ (NSColor *)mgl_colorWithColor:(mbgl::Color)color
|
||||
{
|
||||
return [NSColor colorWithRed:color.r green:color.g blue:color.b alpha:color.a];
|
||||
return [NSColor colorWithCalibratedRed:color.r green:color.g blue:color.b alpha:color.a];
|
||||
}
|
||||
|
||||
- (mbgl::style::PropertyValue<mbgl::Color>)mgl_colorPropertyValue
|
||||
|
||||
Reference in New Issue
Block a user