diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-01-25 01:07:51 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-26 17:19:22 -0800 |
commit | c5017652b97d0e519289b972a6b39762540a61a3 (patch) | |
tree | c6165377400e850de8cf40fb97ebeb6c0dfa69c1 /platform | |
parent | 9b694058b0afdcb30ed2eceebd1ff85a01b2e2ba (diff) | |
download | qtlocation-mapboxgl-c5017652b97d0e519289b972a6b39762540a61a3.tar.gz |
[ios] Turn map around when user dot is top-aligned
Also fixed top- and bottom-aligned user dot center points to account for the content inset’s offset within the map view bounds.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 959e1e7be0..5d0086c21c 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3141,10 +3141,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) if (std::abs(currentPoint.x - correctPoint.x) > 1.0 || std::abs(currentPoint.y - correctPoint.y) > 1.0) { CLLocationDirection course = self.userLocation.location.course; - if (course < 0 || self.userTrackingMode != MGLUserTrackingModeFollowWithCourse) + if (self.userTrackingMode != MGLUserTrackingModeFollowWithCourse) { course = -1; } + else if (course >= 0 && self.userLocationVerticalAlignment == MGLAnnotationVerticalAlignmentTop) + { + course += 180; + } // Shift the center point upward or downward to accommodate a // shifted user location annotation view. @@ -3525,7 +3529,8 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } } -/// Intended center point of the user location annotation view. +/// Intended center point of the user location annotation view with respect to +/// the overall map view (but respecting the content inset). - (CGPoint)userLocationAnnotationViewCenter { CGRect contentFrame = self.contentFrame; @@ -3537,10 +3542,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) case MGLAnnotationVerticalAlignmentCenter: break; case MGLAnnotationVerticalAlignmentTop: - center.y = CGRectGetHeight(self.userLocationAnnotationView.frame) + MGLUserLocationAnnotationViewPadding; + center.y = CGRectGetMinY(contentFrame) + CGRectGetHeight(self.userLocationAnnotationView.frame) + MGLUserLocationAnnotationViewPadding; break; case MGLAnnotationVerticalAlignmentBottom: - center.y = CGRectGetHeight(contentFrame) - CGRectGetHeight(self.userLocationAnnotationView.frame) - MGLUserLocationAnnotationViewPadding; + center.y = CGRectGetMaxY(contentFrame) - CGRectGetHeight(self.userLocationAnnotationView.frame) - MGLUserLocationAnnotationViewPadding; break; } |