summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-06-21 15:21:22 +0200
committerGitHub <noreply@github.com>2016-06-21 15:21:22 +0200
commit3995d6ff68a51dd4543ad71f424adf261e1e8baf (patch)
treec4fbf0eea8d6d88ea900b2dd8ffc1794a5326adf /platform
parenta7d5717cf5a5adb6d2bb5641c81c97c46965b8fa (diff)
downloadqtlocation-mapboxgl-3995d6ff68a51dd4543ad71f424adf261e1e8baf.tar.gz
[ios] fixes #5406 view for annotation (#5413)
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/MGLMapView.h9
-rw-r--r--platform/ios/src/MGLMapView.mm9
2 files changed, 18 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 1319228c1a..d6bc25f961 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -952,6 +952,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.
For performance reasons, you should generally reuse `MGLAnnotationImage`
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index a1a412af01..7f09113f5b 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2984,6 +2984,15 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
return annotationView;
}
+- (nullable MGLAnnotationView *)viewForAnnotation:(id<MGLAnnotation>)annotation
+{
+ MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation];
+ if (annotationTag == MGLAnnotationTagNotFound) return nil;
+
+ MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
+ return annotationContext.annotationView;
+}
+
- (double)alphaForShapeAnnotation:(MGLShape *)annotation
{
if (_delegateHasAlphasForShapeAnnotations)