Added an API for deleting unused annotation images’ images. When you nil out the image of an MGLAnnotationImage, MGLMapView deletes the sprite from the style and recreates any annotation associated with the MGLAnnotationImage instance; the MGLAnnotationImage’s falls back to SDK’s default annotation image. In iosapp, deselecting an annotation resets its image to the default; deselecting it again restores the image. ref #3185
39 lines
886 B
Objective-C
39 lines
886 B
Objective-C
#import "MGLAnnotationImage_Private.h"
|
|
|
|
@interface MGLAnnotationImage ()
|
|
|
|
@property (nonatomic, strong) NSString *reuseIdentifier;
|
|
@property (nonatomic, strong, nullable) NSString *styleIconIdentifier;
|
|
|
|
@property (nonatomic, weak) id<MGLAnnotationImageDelegate> delegate;
|
|
|
|
@end
|
|
|
|
@implementation MGLAnnotationImage
|
|
|
|
+ (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier
|
|
{
|
|
return [[self alloc] initWithImage:image reuseIdentifier:reuseIdentifier];
|
|
}
|
|
|
|
- (instancetype)initWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier
|
|
{
|
|
self = [super init];
|
|
|
|
if (self)
|
|
{
|
|
_image = image;
|
|
_reuseIdentifier = [reuseIdentifier copy];
|
|
_enabled = YES;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)setImage:(UIImage *)image {
|
|
_image = image;
|
|
[self.delegate annotationImageNeedsRedisplay:self];
|
|
}
|
|
|
|
@end
|