forked from organicmaps/organicmaps
Show pin in API, URL, Bookmarks.
This commit is contained in:
parent
e0a21eb1d2
commit
5245e38081
5 changed files with 75 additions and 50 deletions
|
@ -206,72 +206,88 @@ void PinClickManager::Hide()
|
|||
|
||||
void PinClickManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
|
||||
{
|
||||
// By default we assume that we have pin
|
||||
bool dispatched = false;
|
||||
|
||||
// API
|
||||
url_scheme::ResultPoint apiPoint;
|
||||
if (m_f.GetMapApiPoint(pxPoint, apiPoint))
|
||||
{
|
||||
// @todo draw pin here
|
||||
OnActivateAPI(apiPoint);
|
||||
return;
|
||||
m_pinGlobalLocation = apiPoint.GetOrg();
|
||||
dispatched = true;
|
||||
}
|
||||
|
||||
// Everything else
|
||||
search::AddressInfo addrInfo;
|
||||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
// By default we assume that we have pin
|
||||
m_hasPin = true;
|
||||
bool dispatched = false;
|
||||
|
||||
switch (m_f.GetBookmarkOrPoi(pxPoint, pxPivot, addrInfo, bmAndCat))
|
||||
else
|
||||
{
|
||||
case Framework::BOOKMARK:
|
||||
{
|
||||
OnActivateBookmark(bmAndCat);
|
||||
m_pinGlobalLocation = m_f.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second)->GetOrg();
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
// Everything else
|
||||
search::AddressInfo addrInfo;
|
||||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
case Framework::ADDTIONAL_LAYER:
|
||||
switch (m_f.GetBookmarkOrPoi(pxPoint, pxPivot, addrInfo, bmAndCat))
|
||||
{
|
||||
OnAdditonalLayer(bmAndCat.second);
|
||||
m_pinGlobalLocation = m_f.GetBookmarkManager().AdditionalPoiLayerGetBookmark(bmAndCat.second)->GetOrg();
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case Framework::POI:
|
||||
{
|
||||
m2::PointD globalPoint = m_f.PtoG(pxPivot);
|
||||
OnActivatePOI(globalPoint, addrInfo);
|
||||
m_pinGlobalLocation = globalPoint;
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (isLongTouch)
|
||||
case Framework::BOOKMARK:
|
||||
{
|
||||
m2::PointD const glbPoint = m_f.PtoG(pxPoint);
|
||||
m_f.GetAddressInfoForGlobalPoint(glbPoint, addrInfo);
|
||||
OnActivatePOI(glbPoint, addrInfo);
|
||||
m_pinGlobalLocation = glbPoint;
|
||||
OnActivateBookmark(bmAndCat);
|
||||
m_pinGlobalLocation = m_f.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second)->GetOrg();
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case Framework::ADDTIONAL_LAYER:
|
||||
{
|
||||
OnAdditonalLayer(bmAndCat.second);
|
||||
m_pinGlobalLocation = m_f.GetBookmarkManager().AdditionalPoiLayerGetBookmark(bmAndCat.second)->GetOrg();
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case Framework::POI:
|
||||
{
|
||||
m2::PointD globalPoint = m_f.PtoG(pxPivot);
|
||||
OnActivatePOI(globalPoint, addrInfo);
|
||||
m_pinGlobalLocation = globalPoint;
|
||||
dispatched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (isLongTouch)
|
||||
{
|
||||
m2::PointD const glbPoint = m_f.PtoG(pxPoint);
|
||||
m_f.GetAddressInfoForGlobalPoint(glbPoint, addrInfo);
|
||||
OnActivatePOI(glbPoint, addrInfo);
|
||||
m_pinGlobalLocation = glbPoint;
|
||||
dispatched = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!dispatched)
|
||||
SetBalloonVisible(dispatched);
|
||||
}
|
||||
|
||||
void PinClickManager::OnBookmarkClick(BookmarkAndCategory const & bnc)
|
||||
{
|
||||
OnActivateBookmark(bnc);
|
||||
m_pinGlobalLocation = m_f.GetBmCategory(bnc.first)->GetBookmark(bnc.second)->GetOrg();
|
||||
|
||||
SetBalloonVisible(true);
|
||||
}
|
||||
|
||||
void PinClickManager::SetBalloonVisible(bool isVisible)
|
||||
{
|
||||
m_hasPin = isVisible;
|
||||
|
||||
if (isVisible)
|
||||
StartAnimation();
|
||||
else
|
||||
{
|
||||
OnDismiss();
|
||||
m_hasPin = false;
|
||||
ResetAnimation();
|
||||
}
|
||||
else
|
||||
StartAnimation();
|
||||
|
||||
m_f.Invalidate();
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ class PinClickManager
|
|||
void OnAdditonalLayer(size_t index);
|
||||
void OnDismiss();
|
||||
|
||||
void SetBalloonVisible(bool isVisible);
|
||||
|
||||
public:
|
||||
PinClickManager(Framework & f);
|
||||
~PinClickManager();
|
||||
|
@ -51,7 +53,10 @@ public:
|
|||
|
||||
void RenderPolicyCreated(graphics::EDensity density);
|
||||
void LocationChanged(location::GpsInfo const & info);
|
||||
|
||||
void OnClick(m2::PointD const & pxPoint, bool isLongTouch);
|
||||
void OnBookmarkClick(BookmarkAndCategory const & bnc);
|
||||
|
||||
void Hide();
|
||||
|
||||
void DrawPin(shared_ptr<PaintEvent> const & e);
|
||||
|
|
|
@ -453,7 +453,7 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double vi
|
|||
return make_pair(retBookmarkCategory, retBookmark);
|
||||
}
|
||||
|
||||
void Framework::ShowBookmark(BookmarkAndCategory bnc)
|
||||
void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
|
||||
{
|
||||
StopLocationFollow();
|
||||
|
||||
|
@ -465,6 +465,8 @@ void Framework::ShowBookmark(BookmarkAndCategory bnc)
|
|||
scale = scales::GetUpperComfortScale();
|
||||
|
||||
ShowRectExVisibleScale(m_scales.GetRectForDrawScale(scale, bmk->GetOrg()));
|
||||
|
||||
m_balloonManager.OnBookmarkClick(bnc);
|
||||
}
|
||||
|
||||
void Framework::ShowTrack(Track const & track)
|
||||
|
@ -1512,6 +1514,8 @@ bool Framework::ShowMapForURL(string const & url)
|
|||
StopLocationFollow();
|
||||
SetViewPortASync(rect);
|
||||
|
||||
if (result != NO_BALLOON)
|
||||
m_balloonManager.OnClick(GtoP(point.GetOrg()), true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -205,7 +205,7 @@ public:
|
|||
BookmarkAndCategory GetBookmark(m2::PointD const & pxPoint, double visualScale) const;
|
||||
//@}
|
||||
|
||||
void ShowBookmark(BookmarkAndCategory bnc);
|
||||
void ShowBookmark(BookmarkAndCategory const & bnc);
|
||||
void ShowTrack(Track const & track);
|
||||
|
||||
void ClearBookmarks();
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
/// Need to fix default name using "dropped_pin" in Framework.
|
||||
string & GetName() { return m_point.m_name; }
|
||||
|
||||
m2::PointD GetOrg() const { return m_org; }
|
||||
m2::PointD const & GetOrg() const { return m_org; }
|
||||
string const & GetName() const { return m_point.m_name; }
|
||||
ApiPoint const & GetPoint() const { return m_point; }
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue