diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index 0d8ed4bbd7..18494fa764 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -59,7 +59,8 @@ - (void)searchViewDidEnterState:(MWMSearchManagerState)state; - (void)actionDownloadMaps:(mwm::DownloaderMode)mode; - (void)searchFrameUpdated:(CGRect)frame; -- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale; +- (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale; +- (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale; #pragma mark - MWMFeatureHolder diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index a6672fda21..263106b0bd 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -236,12 +236,22 @@ extern NSString * const kAlohalyticsTapEventKey; self.topBound = s.height; } -- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale +- (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale +{ + if (![self searchText:text forInputLocale:locale]) + return; + + self.searchManager.state = MWMSearchManagerStateMapSearch; +} + +- (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale { if (text.length == 0) - return; + return NO; + self.searchManager.state = MWMSearchManagerStateTableSearch; [self.searchManager searchText:text forInputLocale:locale]; + return YES; } #pragma mark - MWMBottomMenuControllerProtocol diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 370a51c4e3..1b9491297c 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -195,6 +195,7 @@ using namespace osm_auth_ios; }); return; } + Framework & f = GetFramework(); if (m_geoURL) { @@ -223,6 +224,7 @@ using namespace osm_auth_ios; auto const points = parsedData.m_points; auto const & p1 = points[0]; auto const & p2 = points[1]; + [[MWMRouter router] buildFromPoint:routePoint(p1.m_org, @(p1.m_name.c_str())) toPoint:routePoint(p2.m_org, @(p2.m_name.c_str())) bestRouter:NO]; @@ -237,6 +239,21 @@ using namespace osm_auth_ios; [self.mapViewController showAPIBar]; } break; + case ParsedMapApi::ParsingResult::Search: + { + auto const & request = f.GetParsedSearchRequest(); + auto manager = [MWMMapViewControlsManager manager]; + + auto query = [@((request.m_query + " ").c_str()) stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + auto locale = @(request.m_locale.c_str()); + + if (request.m_isSearchOnMap) + [manager searchTextOnMap:query forInputLocale:locale]; + else + [manager searchText:query forInputLocale:locale]; + + break; + } } } else if (m_fileURL) diff --git a/iphone/Maps/Core/Search/MWMSearch.h b/iphone/Maps/Core/Search/MWMSearch.h index e1e1385b06..e000c8dd4c 100644 --- a/iphone/Maps/Core/Search/MWMSearch.h +++ b/iphone/Maps/Core/Search/MWMSearch.h @@ -13,7 +13,7 @@ + (void)showResult:(search::Result const &)result; -+ (search::Result &)resultAtIndex:(NSUInteger)index; ++ (search::Result const &)resultAtIndex:(NSUInteger)index; + (void)update; + (void)clear; diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index 27a16ecceb..10c2a00a46 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -209,7 +209,7 @@ using TObservers = NSHashTable<__kindof TObserver>; + (void)showResult:(search::Result const &)result { GetFramework().ShowSearchResult(result); } -+ (search::Result &)resultAtIndex:(NSUInteger)index ++ (search::Result const &)resultAtIndex:(NSUInteger)index { return [MWMSearch manager]->m_everywhereResults.GetResult(index); }