[ios] Detect clicks on already added bookmarks

This commit is contained in:
Alex Zolotarev 2012-08-22 10:02:13 +03:00 committed by Alex Zolotarev
parent c70258b477
commit c8f898c461
2 changed files with 20 additions and 10 deletions

View file

@ -119,10 +119,8 @@
- (void) showInView:(UIView *)view atPoint:(CGPoint)pt
{
if (isDisplayed)
{
NSLog(@"Already displaying the BalloonView");
return;
}
[self hide];
isDisplayed = YES;
CGFloat const w = self.pinImage.bounds.size.width;

View file

@ -137,14 +137,26 @@
- (void)onSingleTap:(NSValue *)point
{
if (m_bookmark.isDisplayed)
[m_bookmark hide];
// Try to check if we've clicked on bookmark
CGPoint const pixelPos = [point CGPointValue];
Bookmark const * bm = GetFramework().GetBookmark(m2::PointD(pixelPos.x, pixelPos.y));
if (!bm)
{
if (m_bookmark.isDisplayed)
[m_bookmark hide];
else
{
CGPoint const globalPos = [self viewPoint2GlobalPoint:pixelPos];
m_bookmark.globalPosition = globalPos;
[m_bookmark showInView:self.view atPoint:pixelPos];
}
}
else
{
CGPoint const pixelPos = [point CGPointValue];
CGPoint const globalPos = [self viewPoint2GlobalPoint:pixelPos];
m_bookmark.globalPosition = globalPos;
[m_bookmark showInView:self.view atPoint:pixelPos];
// Already added bookmark was clicked
m2::PointD const globalPos = bm->GetOrg();
m_bookmark.globalPosition = CGPointMake(globalPos.x, globalPos.y);
[m_bookmark showInView:self.view atPoint:[self globalPoint2ViewPoint:m_bookmark.globalPosition]];
}
}