Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] fixes #5406 view for annotation #5413

Merged
merged 1 commit into from
Jun 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions platform/ios/src/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,15 @@ IB_DESIGNABLE
*/
- (void)removeAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations;

/**
Returns an `MGLAnnotationView` if the given annotation is currently associated
with a view, otherwise nil.

@param annotation The annotation associated with the view.
Annotation must conform to the `MGLAnnotation` protocol.
*/
- (nullable MGLAnnotationView *)viewForAnnotation:(id <MGLAnnotation>)annotation;

/**
Returns a reusable annotation image object associated with its identifier.

Expand Down
9 changes: 9 additions & 0 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2984,6 +2984,15 @@ - (MGLAnnotationView *)annotationViewForAnnotation:(id<MGLAnnotation>)annotation
return annotationView;
}

- (nullable MGLAnnotationView *)viewForAnnotation:(id<MGLAnnotation>)annotation
{
MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation];
if (annotationTag == MGLAnnotationTagNotFound) return nil;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, if the developer passes in userLocation, this method should return the MGLUserLocationAnnotationView, but this is fine for now because MGLUserLocationAnnotationView doesn't subclass MGLAnnotationView yet.


MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
return annotationContext.annotationView;
}

- (double)alphaForShapeAnnotation:(MGLShape *)annotation
{
if (_delegateHasAlphasForShapeAnnotations)
Expand Down