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

Commit

Permalink
[ios] Restored user dot accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Apr 21, 2016
1 parent a746546 commit 9cd6731
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ - (CGRect)accessibilityFrame
- (NSInteger)accessibilityElementCount
{
std::vector<MGLAnnotationTag> visibleAnnotations = [self annotationTagsInRect:self.bounds];
return visibleAnnotations.size() + 2 /* compass, attributionButton */;
return visibleAnnotations.size() + 3 /* compass, userLocationAnnotationView, attributionButton */;
}

- (id)accessibilityElementAtIndex:(NSInteger)index
Expand All @@ -1834,7 +1834,11 @@ - (id)accessibilityElementAtIndex:(NSInteger)index
{
return self.compassView;
}
if (index > 0 && (NSUInteger)index == visibleAnnotations.size() + 1 /* compass */)
if (index == 1)
{
return self.userLocationAnnotationView;
}
if (index > 0 && (NSUInteger)index == visibleAnnotations.size() + 2 /* compass, userLocationAnnotationView */)
{
return self.attributionButton;
}
Expand All @@ -1843,7 +1847,7 @@ - (id)accessibilityElementAtIndex:(NSInteger)index
NSUInteger annotationIndex = MGLAnnotationTagNotFound;
if (index >= 0 && (NSUInteger)index < visibleAnnotations.size())
{
annotationIndex = index - 1 /* compass */;
annotationIndex = index - 2 /* compass, userLocationAnnotationView */;
}
MGLAnnotationTag annotationTag = visibleAnnotations[annotationIndex];
NSAssert(annotationTag != MGLAnnotationTagNotFound, @"Can’t get accessibility element for nonexistent or invisible annotation at index %li.", index);
Expand Down Expand Up @@ -1884,6 +1888,10 @@ - (NSInteger)indexOfAccessibilityElement:(id)element
{
return 0;
}
if (element == self.userLocationAnnotationView)
{
return 1;
}
if ( ! [element isKindOfClass:[MGLAnnotationAccessibilityElement class]] &&
element != self.attributionButton)
{
Expand All @@ -1899,7 +1907,7 @@ - (NSInteger)indexOfAccessibilityElement:(id)element
auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(),
((MGLAnnotationAccessibilityElement *)element).tag);
if (foundElement == visibleAnnotations.end()) return NSNotFound;
else return std::distance(visibleAnnotations.begin(), foundElement) + 1;
else return std::distance(visibleAnnotations.begin(), foundElement) + 2 /* compass, userLocationAnnotationView */;
}

#pragma mark - Geography -
Expand Down Expand Up @@ -4099,6 +4107,8 @@ - (void)updateUserLocationAnnotationViewAnimatedWithDuration:(NSTimeInterval)dur
[self deselectAnnotation:self.selectedAnnotation animated:YES];
}
}

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}

/// Intended center point of the user location annotation view with respect to
Expand Down

0 comments on commit 9cd6731

Please sign in to comment.