diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-01-17 23:33:15 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-20 11:02:31 -0800 |
commit | 07c4c541112d1b5cc74ee4b1e636bfc7501db6ae (patch) | |
tree | 6657d7ba57e234eee508fbad3bab1a98f33d6a9a /platform | |
parent | a93e7d7baa285ab950b216079726d1c38709e3b3 (diff) | |
download | qtlocation-mapboxgl-07c4c541112d1b5cc74ee4b1e636bfc7501db6ae.tar.gz |
[ios] Made user dot position configurable
The user dot or user puck’s position is now configurable via a new alignment property in any user tracking mode. Also, -setUserTrackingMode:animated: is now exposed publicly, and setting its animated parameter to NO skips the initial animation.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 079e5a8432..93b30cb177 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -53,9 +53,9 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingState) { /// The map view is not yet tracking the user location. MGLUserTrackingStatePossible = 0, /// The map view has begun to move to the first reported user location. - MGLUserTrackingStateBegan = 1, + MGLUserTrackingStateBegan, /// The map view has finished moving to the first reported user location. - MGLUserTrackingStateChanged = 2, + MGLUserTrackingStateChanged, }; NSString *const MGLMapboxSetupDocumentationURLDisplayString = @"mapbox.com/help/first-steps-ios-sdk"; @@ -3030,6 +3030,15 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) } } +- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment +{ + _userLocationVerticalAlignment = alignment; + if (self.userTrackingMode != MGLUserTrackingModeNone) + { + [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:YES]; + } +} + - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { [self locationManager:manager didUpdateLocations:locations animated:YES]; @@ -3449,9 +3458,15 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) // When tracking course, it’s more important to see the road ahead, so // weight the user dot down towards the bottom. - if (self.userTrackingMode == MGLUserTrackingModeFollowWithCourse) - { - center.y = CGRectGetHeight(contentFrame) - CGRectGetHeight(self.userLocationAnnotationView.frame); + switch (self.userLocationVerticalAlignment) { + case MGLAnnotationVerticalAlignmentCenter: + break; + case MGLAnnotationVerticalAlignmentTop: + center.y = CGRectGetHeight(self.userLocationAnnotationView.frame); + break; + case MGLAnnotationVerticalAlignmentBottom: + center.y = CGRectGetHeight(contentFrame) - CGRectGetHeight(self.userLocationAnnotationView.frame); + break; } return center; |