forked from organicmaps/organicmaps
Correctly process tap on “Search on the map” result. Fixes undefined behavior.
This commit is contained in:
parent
df03661560
commit
d1950c7dff
3 changed files with 30 additions and 2 deletions
|
@ -697,6 +697,19 @@ void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & inf
|
|||
info.m_apiUrl = GenerateApiBackUrl(api);
|
||||
}
|
||||
|
||||
void Framework::FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const
|
||||
{
|
||||
if (smp.m_foundFeatureID.IsValid())
|
||||
{
|
||||
FillFeatureInfo(smp.m_foundFeatureID, info);
|
||||
info.m_customName = smp.m_matchedName;
|
||||
}
|
||||
else
|
||||
{
|
||||
FillPointInfo(smp.GetPivot(), smp.m_matchedName, info);
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::FillMyPositionInfo(place_page::Info & info) const
|
||||
{
|
||||
double lat, lon;
|
||||
|
@ -974,6 +987,7 @@ void Framework::StartInteractiveSearch(search::SearchParams const & params)
|
|||
m_lastInteractiveSearchParams = params;
|
||||
m_lastInteractiveSearchParams.SetForceSearch(false);
|
||||
m_lastInteractiveSearchParams.SetMode(Mode::Viewport);
|
||||
m_lastInteractiveSearchParams.SetSuggestsEnabled(false);
|
||||
m_lastInteractiveSearchParams.m_onResults = [this](Results const & results)
|
||||
{
|
||||
if (!results.IsEndMarker())
|
||||
|
@ -1291,7 +1305,13 @@ void Framework::FillSearchResultsMarks(search::Results const & results)
|
|||
{
|
||||
search::Result const & r = results.GetResult(i);
|
||||
if (r.HasPoint())
|
||||
UNUSED_VALUE(guard.m_controller.CreateUserMark(r.GetFeatureCenter()));
|
||||
{
|
||||
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(guard.m_controller.CreateUserMark(r.GetFeatureCenter()));
|
||||
ASSERT(mark->GetMarkType() == UserMark::Type::SEARCH, ());
|
||||
if (r.GetResultType() == search::Result::RESULT_FEATURE)
|
||||
mark->m_foundFeatureID = r.GetFeatureID();
|
||||
mark->m_matchedName = r.GetString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1869,7 +1889,7 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(df::TapInfo const
|
|||
FillBookmarkInfo(*static_cast<Bookmark const *>(mark), FindBookmark(mark), outInfo);
|
||||
break;
|
||||
case UserMark::Type::SEARCH:
|
||||
FillApiMarkInfo(*static_cast<ApiMarkPoint const *>(mark), outInfo);
|
||||
FillSearchResultInfo(*static_cast<SearchMarkPoint const *>(mark), outInfo);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, ("FindNearestUserMark returned invalid mark."));
|
||||
|
|
|
@ -479,6 +479,7 @@ private:
|
|||
/// @param customTitle, if not empty, overrides any other calculated name.
|
||||
void FillPointInfo(m2::PointD const & mercator, string const & customTitle, place_page::Info & info) const;
|
||||
void FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const;
|
||||
void FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const;
|
||||
void FillMyPositionInfo(place_page::Info & info) const;
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "drape_frontend/user_marks_provider.hpp"
|
||||
|
||||
#include "indexer/feature_decl.hpp"
|
||||
|
||||
#include "geometry/latlon.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
|
@ -59,6 +61,11 @@ public:
|
|||
|
||||
string GetSymbolName() const override;
|
||||
UserMark::Type GetMarkType() const override;
|
||||
// TODO: Do not use usermarks to store any significant information for UI/core.
|
||||
// Refactor them out to only display some layers on a map.
|
||||
FeatureID m_foundFeatureID;
|
||||
// Used to pass exact search result matched string into a place page.
|
||||
string m_matchedName;
|
||||
};
|
||||
|
||||
class PoiMarkPoint : public SearchMarkPoint
|
||||
|
|
Loading…
Add table
Reference in a new issue