[ios, osx] Added flyToCamera: variation that uses default duration

This commit is contained in:
Minh Nguyễn
2015-12-15 12:51:15 -08:00
committed by Minh Nguyễn
parent 5dd00d1072
commit 4e0e816653
6 changed files with 29 additions and 7 deletions

View File

@@ -218,10 +218,15 @@ IB_DESIGNABLE
* @param completion The block to execute after the animation finishes. */
- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;
/** Uses a ballistic parabolic motion to "fly" the viewpoint to a different location with respect to the map with a default duration based on the length of the flight path.
* @param camera The new viewpoint.
* @param completion The block to execute after the animation finishes. */
- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion;
/** Uses a ballistic parabolic motion to "fly" the viewpoint to a different location with respect to the map with an optional transition duration.
* @param camera The new viewpoint.
* @param duration The amount of time, measured in seconds, that the transition animation should take. Specify `0` to jump to the new viewpoint instantaneously.
* @param completion The block to execute after the animation finishes. */
* @param camera The new viewpoint.
* @param duration The amount of time, measured in seconds, that the transition animation should take. Specify `0` to use the default duration, which is based on the length of the flight path.
* @param completion The block to execute after the animation finishes. */
- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion;
#pragma mark - Converting Map Coordinates

View File

@@ -249,13 +249,21 @@ IB_DESIGNABLE
@param completion The block to execute after the animation finishes. */
- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;
/** Uses a ballistic parabolic motion to “fly” the viewpoint to a different
location with respect to the map with a default duration based on the length
of the flight path.
@param camera The new viewpoint.
@param completion The block to execute after the animation finishes. */
- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion;
/** Uses a ballistic parabolic motion to “fly” the viewpoint to a different
location with respect to the map with an optional transition duration.
@param camera The new viewpoint.
@param duration The amount of time, measured in seconds, that the transition
animation should take. Specify `0` to jump to the new viewpoint
instantaneously.
animation should take. Specify `0` to use the default duration, which is
based on the length of the flight path.
@param completion The block to execute after the animation finishes. */
- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion;

View File

@@ -379,7 +379,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
pitch:arc4random_uniform(60)
heading:arc4random_uniform(360)];
__weak MBXViewController *weakSelf = self;
[self.mapView flyToCamera:camera withDuration:0 completionHandler:^{
[self.mapView flyToCamera:camera completionHandler:^{
MBXViewController *strongSelf = weakSelf;
[strongSelf performSelector:@selector(continueWorldTourWithRemainingAnnotations:)
withObject:annotations

View File

@@ -1808,6 +1808,11 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
[self didChangeValueForKey:@"camera"];
}
- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion
{
[self flyToCamera:camera withDuration:0 completionHandler:completion];
}
- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion
{
_mbglMap->cancelTransitions();

View File

@@ -319,7 +319,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
pitch:arc4random_uniform(60)
heading:arc4random_uniform(360)];
__weak AppDelegate *weakSelf = self;
[self.mapView flyToCamera:camera withDuration:0 completionHandler:^{
[self.mapView flyToCamera:camera completionHandler:^{
AppDelegate *strongSelf = weakSelf;
[strongSelf performSelector:@selector(continueWorldTourWithRemainingAnnotations:)
withObject:annotations

View File

@@ -1008,6 +1008,10 @@ public:
[self didChangeValueForKey:@"camera"];
}
- (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion {
[self flyToCamera:camera withDuration:0 completionHandler:completion];
}
- (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion {
_mbglMap->cancelTransitions();