diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index ce475c3215..c98ca55e01 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -437,11 +437,10 @@ namespace android m_mask = mask; } - void Framework::ShowSearchResult(search::Result const & r) + void Framework::ShowSearchResult(search::Result const & r, size_t index) { m_doLoadState = false; - - m_work.ShowSearchResult(r); + m_work.ShowSearchResult(r, index); } void Framework::CleanSearchLayerOnMap() diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 92f977b2b3..b0d2144e3b 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -90,7 +90,7 @@ namespace android /// Show rect from another activity. Ensure that no LoadState will be called, /// when maim map activity will become active. - void ShowSearchResult(search::Result const & r); + void ShowSearchResult(search::Result const & r, size_t index); bool Search(search::SearchParams const & params); string GetLastSearchQuery() { return m_searchQuery; } diff --git a/android/jni/com/mapswithme/maps/SearchActivity.cpp b/android/jni/com/mapswithme/maps/SearchActivity.cpp index 7793fe59e7..6df437deab 100644 --- a/android/jni/com/mapswithme/maps/SearchActivity.cpp +++ b/android/jni/com/mapswithme/maps/SearchActivity.cpp @@ -157,8 +157,13 @@ public: void ShowItem(int position) { + // 0 -- show all + // 1 -- first + // + // ... + // n -- last if (CheckPosition(position)) - g_framework->ShowSearchResult(m_results.GetResult(position)); + g_framework->ShowSearchResult(m_results.GetResult(position), position - 1); } search::Result const * GetResult(int position, int resultID) diff --git a/map/framework.cpp b/map/framework.cpp index 3ebdaa8283..6f1b231d10 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1221,7 +1221,7 @@ bool Framework::GetCurrentPosition(double & lat, double & lon) const else return false; } -void Framework::ShowSearchResult(search::Result const & res) +void Framework::ShowSearchResult(search::Result const & res, size_t index) { search::Results searchRes; GetSearchEngine()->GetResults(searchRes); @@ -1229,42 +1229,60 @@ void Framework::ShowSearchResult(search::Result const & res) m_bmManager.AdditionalPoiLayerSetVisible(); m_bmManager.AdditionalPoiLayerClear(); - for (size_t i = 0; i < searchRes.GetCount(); ++i) + if (index == -1) // That means show all results { - search::Result const & tmpRes = searchRes.GetResult(i); - m_bmManager.AdditionalPoiLayerAddPoi(Bookmark(tmpRes.GetFeatureCenter(), tmpRes.GetString(), "api_pin")); + LOG(LDEBUG, ("MwmSearch", "All result,", index)); + + m2::RectD resultsRect(searchRes.GetResult(0).GetFeatureCenter(), + searchRes.GetResult(1).GetFeatureCenter()); + + for (size_t i = 0; i < searchRes.GetCount(); ++i) + { + search::Result const & tmpRes = searchRes.GetResult(i); + m_bmManager.AdditionalPoiLayerAddPoi(Bookmark(tmpRes.GetFeatureCenter(), tmpRes.GetString(), "api_pin")); + + if (i > 1) + resultsRect.Add(tmpRes.GetFeatureCenter()); + } + + ShowRectEx(resultsRect); } - - int scale; - m2::PointD center; - - switch (res.GetResultType()) + else // single result { - case search::Result::RESULT_FEATURE: - { - FeatureID const id = res.GetFeatureID(); - Index::FeaturesLoaderGuard guard(m_model.GetIndex(), id.m_mwm); + m_bmManager.AdditionalPoiLayerAddPoi(Bookmark(res.GetFeatureCenter(), res.GetString(), "api_pin")); + LOG(LDEBUG, ("MwmSearch", "Single result,", index)); - FeatureType ft; - guard.GetFeature(id.m_offset, ft); + int scale; + m2::PointD center; - scale = feature::GetFeatureViewportScale(feature::TypesHolder(ft)); - center = feature::GetCenter(ft, scale); - break; - } + switch (res.GetResultType()) + { + case search::Result::RESULT_FEATURE: + { + FeatureID const id = res.GetFeatureID(); + Index::FeaturesLoaderGuard guard(m_model.GetIndex(), id.m_mwm); - case search::Result::RESULT_LATLON: - scale = scales::GetUpperComfortScale(); - center = res.GetFeatureCenter(); - break; + FeatureType ft; + guard.GetFeature(id.m_offset, ft); - default: - ASSERT(false, ()); - return; + scale = feature::GetFeatureViewportScale(feature::TypesHolder(ft)); + center = feature::GetCenter(ft, scale); + break; + } + + case search::Result::RESULT_LATLON: + scale = scales::GetUpperComfortScale(); + center = res.GetFeatureCenter(); + break; + + default: + ASSERT(false, ()); + return; + } + ShowRectExVisibleScale(m_scales.GetRectForDrawScale(scale, center)); } StopLocationFollow(); - ShowRectExVisibleScale(m_scales.GetRectForDrawScale(scale, center)); } bool Framework::GetDistanceAndAzimut(m2::PointD const & point, diff --git a/map/framework.hpp b/map/framework.hpp index ebc499b7ba..27f5ed3d74 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -278,7 +278,7 @@ public: void PrepareSearch(bool hasPt, double lat = 0.0, double lon = 0.0); bool Search(search::SearchParams const & params); bool GetCurrentPosition(double & lat, double & lon) const; - void ShowSearchResult(search::Result const & res); + void ShowSearchResult(search::Result const & res, size_t index); /// Calculate distance and direction to POI for the given position. /// @param[in] point POI's position;