summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-11-20 02:14:55 -0800
committerMinh Nguyễn <mxn@1ec5.org>2015-11-25 15:20:25 -0800
commit2de0a351a0635192bd05116cebdf0103c2638d05 (patch)
tree72679c82e2bf718c329fc83a9249c352305a9173 /include
parente3992c41c354e70f2c6762690b428f0ebbe362f4 (diff)
downloadqtlocation-mapboxgl-2de0a351a0635192bd05116cebdf0103c2638d05.tar.gz
[core] [iOS] Completion handlers for animated methods
Added transition frame and finish functions to CameraOptions. Added Objective-C equivalents to the three main entry points to easeTo() in MGLMapView. Fixes #1581.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/ios/MGLMapView.h25
-rw-r--r--include/mbgl/map/camera.hpp4
2 files changed, 29 insertions, 0 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index 83ef395cf9..edc3ca53f3 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -134,6 +134,14 @@ IB_DESIGNABLE
* @param animated Specify `YES` if you want the map view to animate scrolling, zooming, and rotating to the new location or `NO` if you want the map to display the new location immediately. */
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated;
+/** Changes the center coordinate, zoom level, and direction of the map, calling a completion handler at the end of an optional animation.
+* @param centerCoordinate The new center coordinate for the map.
+* @param zoomLevel The new zoom level for the map.
+* @param direction The new direction for the map, measured in degrees relative to true north.
+* @param animated Specify `YES` if you want the map view to animate scrolling, zooming, and rotating to the new location or `NO` if you want the map to display the new location immediately.
+* @param completion The block executed after the animation finishes. */
+- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion;
+
/** The coordinate bounds visible in the receiver’s viewport.
*
* Changing the value of this property updates the receiver immediately. If you want to animate the change, call `setVisibleCoordinateBounds:animated:` instead. */
@@ -157,6 +165,16 @@ IB_DESIGNABLE
* @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated;
+/** Changes the receiver’s viewport to fit all of the given coordinates and optionally some additional padding on each side.
+* @param coordinates The coordinates that the viewport will show.
+* @param count The number of coordinates. This number must not be greater than the number of elements in `coordinates`.
+* @param insets The minimum padding (in screen points) that will be visible around the given coordinate bounds.
+* @param direction The direction to rotate the map to, measured in degrees relative to true north.
+* @param duration The duration to animate the change in seconds.
+* @param function The timing function to animate the change.
+* @param completion The block executed after the animation finishes. */
+- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;
+
/** Sets the visible region so that the map displays the specified annotations.
*
* Calling this method updates the value in the visibleCoordinateBounds property and potentially other properties to reflect the new map region.
@@ -193,6 +211,13 @@ IB_DESIGNABLE
* @param function A timing function used for the animation. Set this parameter to `nil` for a transition that matches most system animations. If the duration is `0`, this parameter is ignored. */
- (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function;
+/** Moves the viewpoint to a different location with respect to the map with an optional transition duration and timing function.
+* @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 function A timing function used for the animation. Set this parameter to `nil` for a transition that matches most system animations. If the duration is `0`, this parameter is ignored.
+* @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;
+
#pragma mark - Converting Map Coordinates
/** @name Converting Map Coordinates */
diff --git a/include/mbgl/map/camera.hpp b/include/mbgl/map/camera.hpp
index a16c1d4dc2..d787a39e11 100644
--- a/include/mbgl/map/camera.hpp
+++ b/include/mbgl/map/camera.hpp
@@ -7,6 +7,8 @@
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/unitbezier.hpp>
+#include <functional>
+
namespace mbgl {
struct CameraOptions {
@@ -16,6 +18,8 @@ struct CameraOptions {
mapbox::util::optional<double> pitch;
mapbox::util::optional<Duration> duration;
mapbox::util::optional<mbgl::util::UnitBezier> easing;
+ std::function<void(double)> transitionFrameFn;
+ std::function<void()> transitionFinishFn;
};
}