From c9d667165694db29450570687a2ca969fe6f3450 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 2 Jul 2013 21:57:00 +0300 Subject: [PATCH] [api] Fixed bookmark zoom level when using api and ge0/geo schemes --- map/framework.cpp | 13 +++++++++---- map/framework.hpp | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 37d2221d12..07edad800b 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -884,15 +884,19 @@ void Framework::CheckMinGlobalRect(m2::AnyRectD & rect) const rect = minAnyRect; } -void Framework::CheckMinVisibleScale(m2::RectD & rect) const +bool Framework::CheckMinVisibleScale(m2::RectD & rect) const { int const worldS = scales::GetUpperWorldScale(); if (scales::GetScaleLevel(rect) > worldS) { m2::PointD const c = rect.Center(); if (!IsCountryLoaded(c)) + { rect = scales::GetRectForLevel(worldS, c, 1.0); + return true; + } } + return false; } void Framework::ShowRect(m2::RectD const & r) @@ -1456,9 +1460,10 @@ bool Framework::SetViewportByURL(string const & url, url_scheme::ApiPoint & ball void Framework::SetViewPortSync(m2::RectD rect) { - // This is tricky way to syncronize work and - // rendring threads. - CheckMinVisibleScale(rect); + // This is tricky way to syncronize work and rendring threads. + // Quick buben-fix to show correct rect in API when country is not downloaded + if (CheckMinVisibleScale(rect)) + rect.Inflate(0.25, 0.25); m2::AnyRectD aRect(rect); CheckMinGlobalRect(aRect); m_animator.ChangeViewport(aRect, aRect, 0.0); diff --git a/map/framework.hpp b/map/framework.hpp index f7459ca657..fc1d6abfc4 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -363,7 +363,8 @@ public: private: m2::AnyRectD ToRotated(m2::RectD const & rect) const; void CheckMinGlobalRect(m2::AnyRectD & rect) const; - void CheckMinVisibleScale(m2::RectD & rect) const; + /// @return true if rect was fixed to display downloaded zoom level (world map) + bool CheckMinVisibleScale(m2::RectD & rect) const; void ShowRectFixed(m2::AnyRectD const & rect); public: