diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 6c0f136a6..ffe742296 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -199,14 +199,14 @@ void Transform::_setScale(double new_scale, double cx, double cy, const Duration // Zoom in on the center if we don't have click or gesture anchor coordinates. if (cx < 0 || cy < 0) { - cx = current.width / 2; - cy = current.height / 2; + cx = static_cast(current.width) / 2.0; + cy = static_cast(current.height) / 2.0; } // Account for the x/y offset from the center (= where the user clicked or pinched) const double factor = new_scale / current.scale; - const double dx = (cx - current.width / 2) * (1.0 - factor); - const double dy = (cy - current.height / 2) * (1.0 - factor); + const double dx = (cx - static_cast(current.width) / 2.0) * (1.0 - factor); + const double dy = (cy - static_cast(current.height) / 2.0) * (1.0 - factor); // Account for angle const double angle_sin = std::sin(-current.angle); @@ -289,7 +289,7 @@ void Transform::rotateBy(const double start_x, const double start_y, const doubl const double end_y, const Duration duration) { std::lock_guard lock(mtx); - double center_x = current.width / 2, center_y = current.height / 2; + double center_x = static_cast(current.width) / 2.0, center_y = static_cast(current.height) / 2.0; const double begin_center_x = start_x - center_x; const double begin_center_y = start_y - center_y; @@ -328,8 +328,8 @@ void Transform::setAngle(const double new_angle, const double cx, const double c double dx = 0, dy = 0; if (cx >= 0 && cy >= 0) { - dx = (final.width / 2) - cx; - dy = (final.height / 2) - cy; + dx = (static_cast(final.width) / 2.0) - cx; + dy = (static_cast(final.height) / 2.0) - cy; _moveBy(dx, dy, Duration::zero()); }