diff --git a/drape_frontend/screen_operations.cpp b/drape_frontend/screen_operations.cpp index 3950212dce..022625eb8f 100644 --- a/drape_frontend/screen_operations.cpp +++ b/drape_frontend/screen_operations.cpp @@ -260,11 +260,10 @@ bool ApplyScale(m2::PointD const & pixelScaleCenter, double factor, ScreenBase & if (!CheckMaxScale(tmp)) { - // Set scale value slightly less than upper bound, to get closest valid zoom. - auto const correctedScale = GetScale((scales::GetUpperStyleScale() + 1) * 0.995); - tmp.SetScale(correctedScale); - if (!CheckMaxScale(tmp)) + auto const maxScale = GetTileBasedScale(scales::GetUpperStyleScale() + 0.42); + if (maxScale > screen.GetScale() && CheckMaxScale(screen)) return false; + tmp.SetScale(maxScale); } // re-checking the borders, as we might violate them a bit (don't know why). diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp index 30eaa91847..6e301e8d36 100644 --- a/drape_frontend/visual_params.cpp +++ b/drape_frontend/visual_params.cpp @@ -233,6 +233,15 @@ m2::RectD GetRectForDrawScale(double drawScale, m2::PointD const & center) return GetRectForDrawScale(my::rounds(drawScale), center); } +double GetTileBasedScale(double zoomLevel) +{ + VisualParams const & p = VisualParams::Instance(); + auto const factor = pow(2.0, zoomLevel); + auto const len = (MercatorBounds::maxX - MercatorBounds::minX) / factor; + auto const pxLen = static_cast(p.GetTileSize()); + return len / pxLen; +} + uint32_t CalculateTileSize(uint32_t screenWidth, uint32_t screenHeight) { uint32_t const maxSz = max(screenWidth, screenHeight); diff --git a/drape_frontend/visual_params.hpp b/drape_frontend/visual_params.hpp index 90541690e4..bc18faac7f 100644 --- a/drape_frontend/visual_params.hpp +++ b/drape_frontend/visual_params.hpp @@ -92,5 +92,6 @@ float InterpolateByZoomLevels(int index, float lerpCoef, std::vector cons m2::PointF InterpolateByZoomLevels(int index, float lerpCoef, std::vector const & values); double GetNormalizedZoomLevel(double scale, int minZoom = 1); double GetScale(double zoomLevel); +double GetTileBasedScale(double zoomLevel); } // namespace df