forked from organicmaps/organicmaps
[search] Fix bug with current viewport when search mode changes.
This commit is contained in:
parent
fc21bc03b5
commit
2c75acba76
4 changed files with 17 additions and 6 deletions
|
@ -433,7 +433,7 @@ void Framework::CenterAndScaleViewport()
|
|||
m2::PointD const pt = m_locationState.Position();
|
||||
m_navigator.CenterViewport(pt);
|
||||
|
||||
m2::RectD clipRect = m_navigator.Screen().ClipRect();
|
||||
m2::RectD clipRect = GetCurrentViewport();
|
||||
|
||||
double const xMinSize = theMetersFactor * max(m_locationState.ErrorRadius(),
|
||||
MercatorBounds::ConvertMetresToX(pt.x, m_metresMinWidth));
|
||||
|
@ -689,12 +689,12 @@ search::Engine * Framework::GetSearchEngine()
|
|||
|
||||
void Framework::PrepareSearch(bool nearMe, double lat, double lon)
|
||||
{
|
||||
GetSearchEngine()->PrepareSearch(m_navigator.Screen().ClipRect(), nearMe, lat, lon);
|
||||
GetSearchEngine()->PrepareSearch(GetCurrentViewport(), nearMe, lat, lon);
|
||||
}
|
||||
|
||||
void Framework::Search(search::SearchParams const & params)
|
||||
{
|
||||
GetSearchEngine()->Search(params);
|
||||
GetSearchEngine()->Search(params, GetCurrentViewport());
|
||||
}
|
||||
|
||||
bool Framework::GetCurrentPosition(double & lat, double & lon)
|
||||
|
|
|
@ -139,6 +139,7 @@ public:
|
|||
bool isTiling);
|
||||
|
||||
private:
|
||||
inline m2::RectD GetCurrentViewport() const { return m_navigator.Screen().ClipRect(); }
|
||||
search::Engine * GetSearchEngine();
|
||||
public:
|
||||
void PrepareSearch(bool nearMe, double lat = 0.0, double lon = 0.0);
|
||||
|
|
|
@ -110,14 +110,24 @@ void Engine::PrepareSearch(m2::RectD const & viewport, bool nearMe,
|
|||
GetPlatform().RunAsync(bind(&Engine::SetViewportAsync, this, r));
|
||||
}
|
||||
|
||||
void Engine::Search(SearchParams const & params)
|
||||
void Engine::Search(SearchParams const & params, m2::RectD const & viewport)
|
||||
{
|
||||
Platform & p = GetPlatform();
|
||||
|
||||
{
|
||||
threads::MutexGuard guard(m_updateMutex);
|
||||
|
||||
// if we need to restore viewport search ...
|
||||
bool const changed = ((m_params.m_mode != params.m_mode) && !params.IsNearMeMode());
|
||||
|
||||
m_params = params;
|
||||
|
||||
// ... so update current viewport
|
||||
if (changed)
|
||||
p.RunAsync(bind(&Engine::SetViewportAsync, this, viewport));
|
||||
}
|
||||
|
||||
GetPlatform().RunAsync(bind(&Engine::SearchAsync, this));
|
||||
p.RunAsync(bind(&Engine::SearchAsync, this));
|
||||
}
|
||||
|
||||
void Engine::SetViewportAsync(m2::RectD const & viewport)
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
void PrepareSearch(m2::RectD const & viewport, bool nearMe,
|
||||
double lat, double lon);
|
||||
void Search(SearchParams const & params);
|
||||
void Search(SearchParams const & params, m2::RectD const & viewport);
|
||||
|
||||
string GetCountryFile(m2::PointD const & pt) const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue