forked from organicmaps/organicmaps
[ios] Show search result as a bookmark balloon
This commit is contained in:
parent
39fb857125
commit
97fc21ae33
7 changed files with 33 additions and 31 deletions
|
@ -4,6 +4,8 @@
|
|||
#include "../../geometry/point2d.hpp"
|
||||
#include "../../geometry/rect2d.hpp"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
@class BalloonView;
|
||||
|
||||
@interface MapViewController : UIViewController <LocationObserver>
|
||||
|
@ -38,6 +40,8 @@
|
|||
|
||||
-(BOOL) OnProcessURL:(NSString*)url;
|
||||
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(m2::PointD const &)pt withInfo:(Framework::AddressInfo const &)info;
|
||||
|
||||
@property (nonatomic, retain) IBOutlet UIButton * m_myPositionButton;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "../../../gui/controller.hpp"
|
||||
|
||||
#include "Framework.h"
|
||||
#include "RenderContext.hpp"
|
||||
|
||||
|
||||
|
@ -216,6 +215,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(m2::PointD const &)pt withInfo:(Framework::AddressInfo const &)info
|
||||
{
|
||||
m_balloonView.globalPosition = CGPointMake(pt.x, pt.y);
|
||||
[self updatePinTexts:info];
|
||||
[m_balloonView showInView:self.view atPoint:[self globalPoint2ViewPoint:m_balloonView.globalPosition] withBookmark:MakeEmptyBookmarkAndCategory()];
|
||||
}
|
||||
|
||||
- (void) onSingleTap:(NSValue *)point
|
||||
{
|
||||
[self processMapClickAtPoint:[point CGPointValue] longClick:NO];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
@property (nonatomic, retain) IBOutlet MapViewController * m_mapViewController;
|
||||
@property (nonatomic, readonly) LocationManager * m_locationManager;
|
||||
|
||||
+ (MapsAppDelegate *) theApp;
|
||||
+ (MapsAppDelegate *)theApp;
|
||||
|
||||
- (SettingsManager *)settingsManager;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
{
|
||||
[m_locationManager release];
|
||||
[m_settingsManager release];
|
||||
m_mapViewController = nil;
|
||||
self.m_mapViewController = nil;
|
||||
[m_navController release];
|
||||
[m_window release];
|
||||
[super dealloc];
|
||||
|
|
|
@ -2,13 +2,9 @@
|
|||
|
||||
#import "LocationManager.h"
|
||||
#import "SearchSuggestionsCell.h"
|
||||
|
||||
#include "../../std/vector.hpp"
|
||||
#include "../../std/function.hpp"
|
||||
#include "../../std/string.hpp"
|
||||
#import "BalloonView.h"
|
||||
|
||||
class Framework;
|
||||
namespace search { class Result; }
|
||||
|
||||
@interface SearchVC : UIViewController
|
||||
<UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#import "BookmarksVC.h"
|
||||
#import "CustomNavigationView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
|
@ -53,9 +54,7 @@ SearchVC * g_searchVC = nil;
|
|||
- (id)initWithResults:(search::Results const &)res
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
m_results.assign(res.Begin(), res.End());
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -85,8 +84,7 @@ static void OnSearchResultCallback(search::Results const & res)
|
|||
|
||||
@implementation SearchVC
|
||||
|
||||
|
||||
- (id)init
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super initWithNibName:nil bundle:nil]))
|
||||
{
|
||||
|
@ -274,25 +272,14 @@ static void OnSearchResultCallback(search::Results const & res)
|
|||
- (void)searchBar:(UISearchBar *)sender textDidChange:(NSString *)searchText
|
||||
{
|
||||
// Search even with empty string.
|
||||
//if (searchText.length)
|
||||
{
|
||||
search::SearchParams params;
|
||||
[self fillSearchParams:params withText:searchText];
|
||||
[self showIndicator];
|
||||
m_framework->Search(params);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// [g_lastSearchResults release];
|
||||
// g_lastSearchResults = nil;
|
||||
// // Clean the table
|
||||
// [m_table reloadData];
|
||||
//}
|
||||
search::SearchParams params;
|
||||
[self fillSearchParams:params withText:searchText];
|
||||
[self showIndicator];
|
||||
m_framework->Search(params);
|
||||
}
|
||||
|
||||
- (void)onCloseButton:(id)sender
|
||||
{
|
||||
m_framework->DisablePlacemark();
|
||||
[self dismissModalViewControllerAnimated:YES];
|
||||
}
|
||||
//*********** End of SearchBar handlers *************************************
|
||||
|
@ -447,10 +434,16 @@ static void OnSearchResultCallback(search::Results const & res)
|
|||
{
|
||||
// Zoom to the feature
|
||||
case search::Result::RESULT_FEATURE:
|
||||
m_framework->ShowSearchResult(res);
|
||||
{
|
||||
m_framework->ShowSearchResult(res);
|
||||
|
||||
// Same as "Close" button but do not disable placemark
|
||||
[self dismissModalViewControllerAnimated:YES];
|
||||
Framework::AddressInfo info;
|
||||
info.m_name = res.GetString();
|
||||
info.m_types.push_back(res.GetFeatureType());
|
||||
[[MapsAppDelegate theApp].m_mapViewController showSearchResultAsBookmarkAtMercatorPoint:res.GetFeatureCenter() withInfo:info];
|
||||
|
||||
[self onCloseButton:nil];
|
||||
}
|
||||
break;
|
||||
|
||||
case search::Result::RESULT_SUGGESTION:
|
||||
|
|
|
@ -1164,7 +1164,10 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
|
||||
ShowRectExVisibleScale(rect);
|
||||
|
||||
DrawPlacemark(rect.Center());
|
||||
// On iOS, we draw search results as bookmarks
|
||||
#ifndef OMIM_OS_IPHONE
|
||||
DrawPlacemark(res.GetFeatureCenter());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Framework::GetDistanceAndAzimut(search::Result const & res,
|
||||
|
|
Loading…
Add table
Reference in a new issue