diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-01-24 11:38:10 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-26 17:17:25 -0800 |
commit | 87f0174967f6616229f6e7e3398f08ed283d8615 (patch) | |
tree | bf5b614a658e994c2dc0c22e95cf8e088e181ae0 /platform | |
parent | 9dcaab193359f3de1a9d9750363cc547a2e69093 (diff) | |
download | qtlocation-mapboxgl-87f0174967f6616229f6e7e3398f08ed283d8615.tar.gz |
[ios] Various user tracking mode fixes
Setting the user tracking mode without animation now works. Previously, it kept the user dot from ever updating.
Just as a zoom gesture no longer kicks the user out of user tracking mode, programmatically zooming shouldn’t either.
Setting a camera with an invalid center coordinate no longer attempts to change the center coordinate but still changes any other valid properties.
Made animation to new user dot vertical alignment optional.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 3fa5ba78b0..0e9b1ccf4a 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1756,7 +1756,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated { - [self setCenterCoordinate:self.centerCoordinate zoomLevel:zoomLevel animated:animated]; + if (zoomLevel == self.zoomLevel) return; + _mbglMap->cancelTransitions(); + + CGFloat duration = animated ? MGLAnimationDuration : 0; + + _mbglMap->setZoom(zoomLevel, + MGLEdgeInsetsFromNSEdgeInsets(self.contentInset), + MGLDurationInSeconds(duration)); } - (MGLCoordinateBounds)visibleCoordinateBounds @@ -2021,7 +2028,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) - (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MGLMapCamera *)camera { mbgl::CameraOptions options; - options.center = MGLLatLngFromLocationCoordinate2D(camera.centerCoordinate); + if (CLLocationCoordinate2DIsValid(camera.centerCoordinate)) + { + options.center = MGLLatLngFromLocationCoordinate2D(camera.centerCoordinate); + } options.padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); options.zoom = MGLZoomLevelForAltitude(camera.altitude, camera.pitch, camera.centerCoordinate.latitude, @@ -3010,6 +3020,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) { self.userTrackingState = MGLUserTrackingStatePossible; } + if ( ! animated) + { + self.userTrackingState = MGLUserTrackingStateChanged; + } switch (_userTrackingMode) { @@ -3068,10 +3082,15 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) - (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment { + [self setUserLocationVerticalAlignment:alignment animated:YES]; +} + +- (void)setUserLocationVerticalAlignment:(MGLAnnotationVerticalAlignment)alignment animated:(BOOL)animated +{ _userLocationVerticalAlignment = alignment; if (self.userTrackingMode != MGLUserTrackingModeNone) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:YES]; + [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; } } |