diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-06-03 14:43:40 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-06-03 15:13:17 -0700 |
commit | 1fdda914e0af473513982ba0a1c014dc2166eb14 (patch) | |
tree | d8a2f29cd8c196fdd367f06e46372da9df2c80f9 /platform | |
parent | ab5e8fb1837c027dfd3fd8dfb5100c7dabea39dc (diff) | |
download | qtlocation-mapboxgl-1fdda914e0af473513982ba0a1c014dc2166eb14.tar.gz |
[ios] Corrected annotation view accessibility frame
Corrected the accessibility frames of annotation views to match the views’ bounds instead of the bounds of the default annotation image (which could be empty if no default GL point annotation has been added).
Fixes #5038.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index cc2f7c3518..ee4346f27b 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -98,6 +98,9 @@ const CGFloat MGLAnnotationImagePaddingForHitTest = 5; /// Distance from the callout’s anchor point to the annotation it points to. const CGFloat MGLAnnotationImagePaddingForCallout = 1; +/// Minimum size of an annotation’s accessibility element. +const CGSize MGLAnnotationAccessibilityElementMinimumSize = CGSizeMake(10, 10); + /// Unique identifier representing a single annotation in mbgl. typedef uint32_t MGLAnnotationTag; @@ -2025,8 +2028,22 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } // Update the accessibility element. - MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag]; - CGRect annotationFrame = [self frameOfImage:annotationImage.image centeredAtCoordinate:annotation.coordinate]; + MGLAnnotationView *annotationView = annotationContext.annotationView; + CGRect annotationFrame; + if (annotationView && annotationView.superview) + { + annotationFrame = [self convertRect:annotationView.bounds fromView:annotationView]; + } + else + { + MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag]; + annotationFrame = [self frameOfImage:annotationImage.image centeredAtCoordinate:annotation.coordinate]; + } + CGPoint annotationFrameCenter = CGPointMake(CGRectGetMidX(annotationFrame), CGRectGetMidY(annotationFrame)); + CGRect minimumFrame = CGRectInset({ annotationFrameCenter, CGSizeZero }, + -MGLAnnotationAccessibilityElementMinimumSize.width / 2, + -MGLAnnotationAccessibilityElementMinimumSize.height / 2); + annotationFrame = CGRectUnion(annotationFrame, minimumFrame); CGRect screenRect = UIAccessibilityConvertFrameToScreenCoordinates(annotationFrame, self); annotationContext.accessibilityElement.accessibilityFrame = screenRect; annotationContext.accessibilityElement.accessibilityHint = NSLocalizedStringWithDefaultValue(@"ANNOTATION_A11Y_HINT", nil, nil, @"Shows more info", @"Accessibility hint"); |