diff options
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index eab40a6ee5..67729f7fe2 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -384,52 +384,28 @@ ScreenCoordinate Transform::getScreenCoordinate(const EdgeInsets& padding) const #pragma mark - Zoom -void Transform::scaleBy(double ds, const AnimationOptions& animation) { - scaleBy(ds, optional<ScreenCoordinate> {}, animation); -} - -void Transform::scaleBy(double ds, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - if (std::isnan(ds)) return; - double scale = util::clamp(state.scale * ds, state.min_scale, state.max_scale); - setScale(scale, anchor, animation); -} - void Transform::setZoom(double zoom, const AnimationOptions& animation) { - setZoom(zoom, optional<ScreenCoordinate> {}, animation); + CameraOptions camera; + camera.zoom = zoom; + easeTo(camera, animation); } void Transform::setZoom(double zoom, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - setScale(state.zoomScale(zoom), anchor, animation); + CameraOptions camera; + camera.zoom = zoom; + camera.anchor = anchor; + easeTo(camera, animation); } void Transform::setZoom(double zoom, const EdgeInsets& padding, const AnimationOptions& animation) { - setScale(state.zoomScale(zoom), padding, animation); -} - -double Transform::getZoom() const { - return state.getZoom(); -} - -double Transform::getScale() const { - return state.scale; -} - -void Transform::setScale(double scale, const AnimationOptions& animation) { - setScale(scale, optional<ScreenCoordinate> {}, animation); -} - -void Transform::setScale(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - if (std::isnan(scale)) return; CameraOptions camera; - camera.zoom = state.scaleZoom(scale); - camera.anchor = anchor; + camera.zoom = zoom; + if (!padding.isFlush()) camera.anchor = getScreenCoordinate(padding); easeTo(camera, animation); } -void Transform::setScale(double scale, const EdgeInsets& padding, const AnimationOptions& animation) { - optional<ScreenCoordinate> anchor; - if (!padding.isFlush()) anchor = getScreenCoordinate(padding); - setScale(scale, anchor, animation); +double Transform::getZoom() const { + return state.getZoom(); } #pragma mark - Bounds |