diff --git a/iOS/offlineguides/AppDelegate.mm b/iOS/offlineguides/AppDelegate.mm index 1299c69..a16bc71 100644 --- a/iOS/offlineguides/AppDelegate.mm +++ b/iOS/offlineguides/AppDelegate.mm @@ -1,6 +1,7 @@ #import "AppDelegate.h" #import "ArticleVC.h" #import "IPadSplitVC.h" +#import "MapsWithMeAPI.h" @implementation AppDelegate @@ -15,4 +16,22 @@ return YES; } +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + sourceApplication:(NSString *)sourceApplication + annotation:(id)annotation +{ + if ([MWMApi isMapsWithMeUrl:url]) + { + MWMPin * pin = [MWMApi pinFromUrl:url]; + if (pin) + { + // @TODO Show corresponding article + NSLog(@"@TODO Show article %@", pin.idOrUrl); + } + return YES; + } + return NO; +} + @end diff --git a/iOS/offlineguides/ArticleVC.mm b/iOS/offlineguides/ArticleVC.mm index f9768ae..83e42f8 100644 --- a/iOS/offlineguides/ArticleVC.mm +++ b/iOS/offlineguides/ArticleVC.mm @@ -2,6 +2,8 @@ #import "GuideVC.h" #import "GuideCell.h" +#import "MapsWithMeAPI.h" + #import "../../storage/storage.hpp" #import "../../env/assert.hpp" @@ -22,6 +24,24 @@ @implementation ArticleVC +- (void)onShowMap:(id)button +{ + size_t const count = m_storage.GetResultsCount(); + NSMutableArray * pins = [[NSMutableArray alloc] initWithCapacity:count]; + + for (size_t i = 0; i < count; ++ i) + { + ArticleInfo const & article = m_storage.GetResult(i); + if (!article.IsRedirect() && article.IsValidCoordinates()) + { + NSString * title = [NSString stringWithUTF8String:article.GetTitle().c_str()]; + NSString * pageId = [NSString stringWithUTF8String:article.GetUrl().c_str()]; + [pins addObject:[[MWMPin alloc] initWithLat:article.m_lat lon:article.m_lon title:title andId:pageId]]; + } + } + [MWMApi showPins:pins]; +} + - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style];