diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-09-11 00:36:52 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-11-02 15:19:54 -0700 |
commit | 0cf4b96bab568203fee54fb08ae520d7d2ce4ad4 (patch) | |
tree | 8434972102726ef04bdb073bef3e36a55738b646 | |
parent | ac7ce2f6afccf395dd771f76534e8d114bedcf86 (diff) | |
download | qtlocation-mapboxgl-0cf4b96bab568203fee54fb08ae520d7d2ce4ad4.tar.gz |
[ios] Made unioned roads accessible
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 0c5ff378dd..5b6b2612ff 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2609,10 +2609,7 @@ public: element = [[MGLRoadFeatureAccessibilityElement alloc] initWithAccessibilityContainer:self feature:feature]; } - if ([feature isKindOfClass:[MGLShapeCollectionFeature class]]) - { - feature = [(MGLShapeCollectionFeature *)feature shapes].firstObject; - } + UIBezierPath *path; if ([feature isKindOfClass:[MGLPointFeature class]]) { CGPoint center = [self convertCoordinate:feature.coordinate toPointToView:self]; @@ -2622,21 +2619,19 @@ public: } else if ([feature isKindOfClass:[MGLPolylineFeature class]]) { - CLLocationCoordinate2D *coordinates = [(MGLPolylineFeature *)feature coordinates]; - NSUInteger pointCount = [(MGLPolylineFeature *)feature pointCount]; - UIBezierPath *path = [UIBezierPath bezierPath]; - for (NSUInteger i = 0; i < pointCount; i++) + path = [self pathOfPolyline:(MGLPolyline *)feature]; + } + else if ([feature isKindOfClass:[MGLMultiPolylineFeature class]]) + { + path = [UIBezierPath bezierPath]; + for (MGLPolyline *polyline in [(MGLMultiPolylineFeature *)feature polylines]) { - CGPoint point = [self convertCoordinate:coordinates[i] toPointToView:self]; - if (i) - { - [path addLineToPoint:point]; - } - else - { - [path moveToPoint:point]; - } + [path appendPath:[self pathOfPolyline:polyline]]; } + } + + if (path) + { CGPathRef strokedCGPath = CGPathCreateCopyByStrokingPath(path.CGPath, NULL, MGLAnnotationAccessibilityElementMinimumSize.width, kCGLineCapButt, kCGLineJoinMiter, 0); UIBezierPath *strokedPath = [UIBezierPath bezierPathWithCGPath:strokedCGPath]; CGPathRelease(strokedCGPath); @@ -2649,6 +2644,26 @@ public: return element; } +- (UIBezierPath *)pathOfPolyline:(MGLPolyline *)polyline +{ + CLLocationCoordinate2D *coordinates = polyline.coordinates; + NSUInteger pointCount = polyline.pointCount; + UIBezierPath *path = [UIBezierPath bezierPath]; + for (NSUInteger i = 0; i < pointCount; i++) + { + CGPoint point = [self convertCoordinate:coordinates[i] toPointToView:self]; + if (i) + { + [path addLineToPoint:point]; + } + else + { + [path moveToPoint:point]; + } + } + return path; +} + - (NSInteger)indexOfAccessibilityElement:(id)element { if (self.calloutViewForSelectedAnnotation) @@ -2671,6 +2686,12 @@ public: return userLocationAnnotationRange.location; } + CGPoint centerPoint = self.contentCenter; + if (self.userTrackingMode != MGLUserTrackingModeNone) + { + centerPoint = self.userLocationAnnotationViewCenter; + } + // Visible annotations std::vector<MGLAnnotationTag> visibleAnnotations = [self annotationTagsInRect:self.bounds]; NSRange visibleAnnotationRange = NSMakeRange(NSMaxRange(userLocationAnnotationRange), visibleAnnotations.size()); |