forked from organicmaps/organicmaps
[core] Search layer of pins added
This commit is contained in:
parent
f9d6e0cf4c
commit
53e3b3f692
6 changed files with 58 additions and 3 deletions
|
@ -109,6 +109,17 @@ void BalloonManager::ShowBookmark(BookmarkAndCategory bmAndCat)
|
|||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateBookmark, this, _1, bmAndCat));
|
||||
}
|
||||
|
||||
void BalloonManager::ShowAdditionalLayerBookmark(size_t index)
|
||||
{
|
||||
ASSERT(index < m_f.AdditionalLayerNumberOfPoi(), ());
|
||||
Bookmark const * pBM = m_f.AdditionalPoiLayerGetBookmark(index);
|
||||
Show(pBM->GetOrg(), pBM->GetName(), "", true);
|
||||
|
||||
search::AddressInfo info;
|
||||
info.m_name = pBM->GetName();
|
||||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivatePOI, this, _1, info));
|
||||
}
|
||||
|
||||
void BalloonManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
|
||||
{
|
||||
url_scheme::ResultPoint apiPoint;
|
||||
|
@ -131,6 +142,12 @@ void BalloonManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
|
|||
return;
|
||||
}
|
||||
|
||||
case Framework::ADDTIONAL_LAYER:
|
||||
{
|
||||
ShowAdditionalLayerBookmark(bmAndCat.second);
|
||||
return;
|
||||
}
|
||||
|
||||
case Framework::POI:
|
||||
if (!m_balloon->isVisible())
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void ShowAddress(m2::PointD const & pt, search::AddressInfo const & info);
|
||||
void ShowURLPoint(url_scheme::ResultPoint const & point, bool needPadding);
|
||||
void ShowBookmark(BookmarkAndCategory bmAndCat);
|
||||
void ShowAdditionalLayerBookmark(size_t index);
|
||||
|
||||
void OnClick(m2::PointD const & pxPoint, bool isLongTouch);
|
||||
|
||||
|
|
|
@ -1223,6 +1223,22 @@ bool Framework::GetCurrentPosition(double & lat, double & lon) const
|
|||
|
||||
void Framework::ShowSearchResult(search::Result const & res)
|
||||
{
|
||||
#ifdef DO_NOT_INCLUDE_IN_RELEASE
|
||||
search::Results searchRes;
|
||||
GetSearchEngine()->GetResults(searchRes);
|
||||
|
||||
m_bmManager.AdditionalPoiLayerSetVisible();
|
||||
m_bmManager.AdditionalPoiLayerClear();
|
||||
size_t resIndex = numeric_limits<size_t>::max();
|
||||
for (size_t i = 0; i < searchRes.GetCount(); ++i)
|
||||
{
|
||||
search::Result const & tmpRes = searchRes.GetResult(i);
|
||||
m_bmManager.AdditionalPoiLayerAddPoi(Bookmark(tmpRes.GetFeatureCenter(), tmpRes.GetString(), "placemark-orange"));
|
||||
if (res == tmpRes)
|
||||
resIndex = i;
|
||||
}
|
||||
#endif
|
||||
|
||||
int scale;
|
||||
m2::PointD center;
|
||||
|
||||
|
@ -1255,9 +1271,13 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
|
||||
ShowRectExVisibleScale(m_scales.GetRectForDrawScale(scale, center));
|
||||
|
||||
#ifdef DO_NOT_INCLUDE_IN_RELEASE
|
||||
m_balloonManager.ShowAdditionalLayerBookmark(resIndex);
|
||||
#else
|
||||
search::AddressInfo info;
|
||||
info.MakeFrom(res);
|
||||
m_balloonManager.ShowAddress(center, info);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Framework::GetDistanceAndAzimut(m2::PointD const & point,
|
||||
|
@ -1576,6 +1596,8 @@ Framework::BookmarkOrPoi Framework::GetBookmarkOrPoi(m2::PointD const & pxPoint,
|
|||
bmCat = GetBookmark(pxPoint);
|
||||
if (IsValid(bmCat))
|
||||
return Framework::BOOKMARK;
|
||||
else if (m_bmManager.IsAdditionalLayerPoi(bmCat))
|
||||
return Framework::ADDTIONAL_LAYER;
|
||||
|
||||
if (GetVisiblePOI(pxPoint, pxPivot, info))
|
||||
{
|
||||
|
|
|
@ -359,7 +359,8 @@ public:
|
|||
{
|
||||
NOTHING_FOUND = 0,
|
||||
BOOKMARK = 1,
|
||||
POI = 2
|
||||
POI = 2,
|
||||
ADDTIONAL_LAYER = 3
|
||||
};
|
||||
|
||||
BookmarkOrPoi GetBookmarkOrPoi(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "search_engine.hpp"
|
||||
#include "result.hpp"
|
||||
#include "search_query.hpp"
|
||||
|
||||
#include "../storage/country_info.hpp"
|
||||
|
@ -175,6 +174,12 @@ bool Engine::Search(SearchParams const & params, m2::RectD const & viewport)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Engine::GetResults(Results & res)
|
||||
{
|
||||
threads::MutexGuard guard(m_searchMutex);
|
||||
m_searchResults.Swap(res);
|
||||
}
|
||||
|
||||
void Engine::SetViewportAsync(m2::RectD const & viewport, m2::RectD const & nearby)
|
||||
{
|
||||
// First of all - cancel previous query.
|
||||
|
@ -327,7 +332,10 @@ void Engine::SearchAsync()
|
|||
// Emit results even if search was canceled and we have something.
|
||||
size_t const count = res.GetCount();
|
||||
if (!m_pQuery->IsCanceled() || count > 0)
|
||||
{
|
||||
m_searchResults = res;
|
||||
EmitResults(params, res);
|
||||
}
|
||||
|
||||
// Make additional search in whole mwm when not enough results (only for non-empty query).
|
||||
if (!emptyQuery && !m_pQuery->IsCanceled() && count < RESULTS_COUNT)
|
||||
|
@ -344,7 +352,10 @@ void Engine::SearchAsync()
|
|||
|
||||
// Emit if we have more results.
|
||||
if (res.GetCount() > count)
|
||||
{
|
||||
m_searchResults = res;
|
||||
EmitResults(params, res);
|
||||
}
|
||||
}
|
||||
|
||||
// Emit finish marker to client.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "params.hpp"
|
||||
#include "result.hpp"
|
||||
|
||||
#include "../geometry/rect2d.hpp"
|
||||
|
||||
|
@ -19,13 +20,13 @@ namespace search
|
|||
{
|
||||
|
||||
class Query;
|
||||
class Results;
|
||||
|
||||
class EngineData;
|
||||
|
||||
class Engine
|
||||
{
|
||||
typedef function<void (Results const &)> SearchCallbackT;
|
||||
Results m_searchResults;
|
||||
|
||||
public:
|
||||
typedef Index IndexType;
|
||||
|
@ -42,6 +43,8 @@ public:
|
|||
bool hasPt, double lat, double lon);
|
||||
bool Search(SearchParams const & params, m2::RectD const & viewport);
|
||||
|
||||
void GetResults(Results & res);
|
||||
|
||||
string GetCountryFile(m2::PointD const & pt);
|
||||
string GetCountryCode(m2::PointD const & pt);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue