forked from organicmaps/organicmaps
[ios] Search via api.
This commit is contained in:
parent
b64aa68716
commit
3cfa7fa590
5 changed files with 33 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue