Merge pull request #1274 from Adlai-Holler/AHMapNodeVendAnnotations

[ASMapNode] Promote annotations to a Formal Property
This commit is contained in:
appleguy 2016-02-25 14:46:33 -08:00
commit 6e85ad8170
2 changed files with 13 additions and 5 deletions

View File

@ -48,10 +48,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) id <MKMapViewDelegate> mapDelegate; @property (nonatomic, weak) id <MKMapViewDelegate> mapDelegate;
/** /**
* @discussion This method sets the annotations of the static map view and also to the live map view. Passing an empty array clears the map of any annotations. * @abstract The annotations to display on the map.
* @param annotations An array of objects that conform to the MKAnnotation protocol
*/ */
- (void)setAnnotations:(NSArray<id<MKAnnotation>> *)annotations; @property (nonatomic, copy) NSArray<id<MKAnnotation>> *annotations;
@end @end

View File

@ -43,6 +43,7 @@
_needsMapReloadOnBoundsChange = YES; _needsMapReloadOnBoundsChange = YES;
_liveMap = NO; _liveMap = NO;
_centerCoordinateOfMap = kCLLocationCoordinate2DInvalid; _centerCoordinateOfMap = kCLLocationCoordinate2DInvalid;
_annotations = @[];
return self; return self;
} }
@ -251,10 +252,18 @@
_mapView = nil; _mapView = nil;
} }
- (void)setAnnotations:(NSArray *)annotations - (NSArray *)annotations
{ {
ASDN::MutexLocker l(_propertyLock); ASDN::MutexLocker l(_propertyLock);
_annotations = [annotations copy]; return _annotations;
}
- (void)setAnnotations:(NSArray *)annotations
{
annotations = [annotations copy] ?: @[];
ASDN::MutexLocker l(_propertyLock);
_annotations = annotations;
if (self.isLiveMap) { if (self.isLiveMap) {
[_mapView removeAnnotations:_mapView.annotations]; [_mapView removeAnnotations:_mapView.annotations];
[_mapView addAnnotations:annotations]; [_mapView addAnnotations:annotations];