diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-05-09 23:52:01 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-04-25 00:15:56 -0700 |
commit | 9350075812b524884003aa5b4e860ef856fcf49d (patch) | |
tree | 284d3ebfc835faeeb41e556bdd0acb66be5ce9b4 | |
parent | bf313b0c5fb17569ba69be63bfc8af41fd5cffa6 (diff) | |
download | qtlocation-mapboxgl-9350075812b524884003aa5b4e860ef856fcf49d.tar.gz |
[ios] VoiceOver support for MGLMapView
Enabled direct interaction with `MGLMapView`, allowing for panning and so forth. Defined an accessibility value that announces the current center coordinate. Inset the map view accessibility frame to exclude ornaments from the interactive element.
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 3d3666c6f6..34078430f8 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -217,6 +217,8 @@ public: BOOL _delegateHasStrokeColorsForShapeAnnotations; BOOL _delegateHasFillColorsForShapeAnnotations; BOOL _delegateHasLineWidthsForShapeAnnotations; + + MGLCoordinateFormatter *_accessibilityCoordinateFormatter; } #pragma mark - Setup & Teardown - @@ -303,7 +305,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) [self createGLView]; } + // setup accessibility + // + self.isAccessibilityElement = YES; self.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"MAP_A11Y_LABEL", nil, nil, @"Map", @"Accessibility label"); + self.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction; + _accessibilityCoordinateFormatter = [[MGLCoordinateFormatter alloc] init]; + _accessibilityCoordinateFormatter.unitStyle = NSFormattingUnitStyleLong; + self.backgroundColor = [UIColor clearColor]; self.clipsToBounds = YES; @@ -1756,6 +1765,36 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _mbglMap->onLowMemory(); } +#pragma mark - Accessibility - + +- (CGRect)accessibilityFrame +{ + CGRect frame = [super accessibilityFrame]; + UIViewController *viewController = self.viewControllerForLayoutGuides; + if (viewController) + { + UIView *compassContainer = self.compassView.superview; + CGFloat topInset = compassContainer.frame.origin.y + compassContainer.frame.size.height + 5; + frame.origin.y += topInset; + frame.size.height -= topInset; + + CGFloat bottomInset = MIN(self.logoView.frame.origin.y, self.attributionButton.frame.origin.y) - 8; + frame.size.height = bottomInset - frame.origin.y; + } + return frame; +} + +- (NSString *)accessibilityValue +{ + // Each arcminute of longitude is at most about 1 nmi, too small for low zoom levels. + // Each arcsecond of longitude is at most about 30 m, too small for all but the very highest of zoom levels. + _accessibilityCoordinateFormatter.allowsMinutes = self.zoomLevel > 8; + _accessibilityCoordinateFormatter.allowsSeconds = self.zoomLevel > 20; + + return [NSString stringWithFormat:@"Centered on %@", + [_accessibilityCoordinateFormatter stringFromCoordinate:self.centerCoordinate]]; +} + #pragma mark - Geography - + (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingCenterCoordinate |