diff --git a/iphone/Maps/Bookmarks/BalloonView.h b/iphone/Maps/Bookmarks/BalloonView.h index ab2bde695c..d264ee3953 100644 --- a/iphone/Maps/Bookmarks/BalloonView.h +++ b/iphone/Maps/Bookmarks/BalloonView.h @@ -11,6 +11,8 @@ SEL m_selector; } +@property(nonatomic, retain) NSString * title; +@property(nonatomic, retain) NSString * description; @property(nonatomic, assign, readonly) BOOL isDisplayed; @property(nonatomic, assign) CGPoint glbPos; diff --git a/iphone/Maps/Bookmarks/BalloonView.mm b/iphone/Maps/Bookmarks/BalloonView.mm index dfc2824aac..1df862b06d 100644 --- a/iphone/Maps/Bookmarks/BalloonView.mm +++ b/iphone/Maps/Bookmarks/BalloonView.mm @@ -3,6 +3,8 @@ @implementation BalloonView +@synthesize title; +@synthesize description; @synthesize isDisplayed; - (void) setGlobalPos:(m2::PointD const &)pt @@ -36,9 +38,9 @@ - (void) showButtonsInView:(UIView *)view atPoint:(CGPoint)pt { m_titleView = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"BookmarkTitle"]; - m_titleView.textLabel.text = @"Bookmark Name"; + m_titleView.textLabel.text = title; m_titleView.textLabel.textColor = [UIColor whiteColor]; - m_titleView.detailTextLabel.text = @"Belarus, Minsk, Kirova 3"; + m_titleView.detailTextLabel.text = description; m_titleView.detailTextLabel.textColor = [UIColor whiteColor]; m_titleView.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; m_titleView.backgroundColor = [UIColor blackColor]; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 77e3df7dbc..32b7f68e7a 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -11,6 +11,31 @@ #include "../../map/framework_factory.hpp" +static string formatAddress(string const & house, string const & street, + string const & city, string const & country) +{ + string result = house; + if (!street.empty()) + { + if (!result.empty()) + result += ' '; + result += street; + } + if (!city.empty()) + { + if (!result.empty()) + result += ' '; + result += city; + } + if (!country.empty()) + { + if (!result.empty()) + result += ' '; + result += country; + } + return result; +} + @implementation MapViewController @synthesize m_myPositionButton; @@ -147,9 +172,14 @@ Framework * m_framework = NULL; if (m_bookmark.isDisplayed) [m_bookmark hide]; - CGPoint const pt = [point CGPointValue]; - m_bookmark.glbPos = [self viewPoint2GlobalPoint:pt]; - [m_bookmark showInView:self.view atPoint:pt]; + CGPoint const pixelPos = [point CGPointValue]; + m2::PointD const globalPos = [self viewPoint2GlobalPoint:pixelPos]; + Framework::AddressInfo addr; + m_framework->GetAddressInfo(globalPos, addr); + m_bookmark.title = [NSString stringWithUTF8String:addr.m_name.c_str()]; + m_bookmark.description = [NSString stringWithUTF8String:formatAddress(addr.m_house, addr.m_street, addr.m_city, addr.m_country).c_str()]; + [m_bookmark setGlobalPos:globalPos]; + [m_bookmark showInView:self.view atPoint:pixelPos]; } - (void) dealloc @@ -268,8 +298,6 @@ NSInteger compareAddress(id l, id r, void * context) } m_isSticking = true; - - [self updateDataAfterScreenChanged]; } - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event