[ios] Added mwm api code. @TODO Add button in UI
This commit is contained in:
parent
e524be387d
commit
a8391c0d2d
2 changed files with 39 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
Reference in a new issue