diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index d4a54cb757..10d1ea491e 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -33,6 +33,8 @@ - (id) initWithCoder: (NSCoder *)coder; +- (void) ZoomToRect: (m2::RectD const &) rect; + - (void) UpdateIcon: (NSTimer *)theTimer; - (void) OnUpdateLocation: (m2::PointD const &) mercatorPoint withErrorRadius: (double) errorRadius diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 2afa38dd6d..935aaf75c7 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -26,6 +26,11 @@ typedef FrameWork framework_t; shared_ptr m_locator; storage::Storage m_storage; +- (void) ZoomToRect: (m2::RectD const &) rect +{ + if (m_framework) + m_framework->ShowRect(rect); +} - (void)UpdateIcon:(NSTimer *)theTimer { diff --git a/iphone/Maps/Settings/CountriesViewController.mm b/iphone/Maps/Settings/CountriesViewController.mm index 249894d6ff..cde3a37e46 100644 --- a/iphone/Maps/Settings/CountriesViewController.mm +++ b/iphone/Maps/Settings/CountriesViewController.mm @@ -125,6 +125,17 @@ static bool IsOurIndex(TIndex const & theirs, TIndex const & ours) // return nil; //} +- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath +{ + TIndex index = CalculateIndex(m_index, indexPath); + if (m_storage->CountryStatus(index) == EOnDisk) + { + m2::RectD bounds = m_storage->CountryBounds(index); + [[MapsAppDelegate theApp].settingsManager Hide]; + [[MapsAppDelegate theApp].mapViewController ZoomToRect:bounds]; + } +} + - (NSInteger) tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section { return m_storage->CountriesCount(m_index); @@ -164,6 +175,8 @@ static bool IsOurIndex(TIndex const & theirs, TIndex const & ours) blue:68.f/255.f alpha:1.f]; cell.detailTextLabel.text = [NSString stringWithFormat: @"Downloaded (%qu %s), touch to delete", size, kBorMBorGB]; + // also add "sight" icon for centering on the country + cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; } break; case EDownloading: diff --git a/map/framework.hpp b/map/framework.hpp index 067493476b..04c9a8a9f5 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -521,6 +521,12 @@ public: UpdateNow(); } + void ShowRect(m2::RectD const & rect) + { + m_navigator.SetFromRect(rect); + UpdateNow(); + } + void MemoryWarning() { // clearing caches on memory warning. diff --git a/storage/storage.cpp b/storage/storage.cpp index 8e83079acb..e968f12a0f 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -266,6 +266,12 @@ namespace storage for_each(country.Tiles().begin(), country.Tiles().end(), DeleteMap()); } + m2::RectD Storage::CountryBounds(TIndex const & index) const + { + Country const & country = CountryByIndex(index); + return country.Bounds(); + } + void Storage::DeleteCountry(TIndex const & index) { Country const & country = CountryByIndex(index); diff --git a/storage/storage.hpp b/storage/storage.hpp index e20387e3f8..fa626fe358 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -128,6 +128,7 @@ namespace storage string CountryName(TIndex const & index) const; TLocalAndRemoteSize CountrySizeInBytes(TIndex const & index) const; TStatus CountryStatus(TIndex const & index) const; + m2::RectD CountryBounds(TIndex const & index) const; void DownloadCountry(TIndex const & index); void DeleteCountry(TIndex const & index);