Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for tiled image map view controller + bugs + docs + zoom. #20

Merged
merged 7 commits into from
Mar 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demo/Demo/NAAnimatedDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NAAnimatedDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAAnimatedDemoViewController.h"
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NAAnnotationDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Daniel Doubrovkine on 3/7/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
4 changes: 2 additions & 2 deletions Demo/Demo/NAAnnotationDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Daniel Doubrovkine on 3/7/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAAnnotationDemoViewController.h"
Expand All @@ -16,7 +16,7 @@ - (void)viewDidLoad
[super viewDidLoad];

NAMapView *mapView = [[NAMapView alloc] initWithFrame:self.view.bounds];

mapView.mapViewDelegate = self;
mapView.backgroundColor = [UIColor colorWithRed:0.000f green:0.475f blue:0.761f alpha:1.000f];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand Down
3 changes: 1 addition & 2 deletions Demo/Demo/NAAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface NAAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) UINavigationController *navigationController;

@end
29 changes: 1 addition & 28 deletions Demo/Demo/NAAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAAppDelegate.h"
Expand All @@ -24,31 +24,4 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
2 changes: 1 addition & 1 deletion Demo/Demo/NAInteractiveDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
63 changes: 29 additions & 34 deletions Demo/Demo/NAInteractiveDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAInteractiveDemoViewController.h"
#import "NAPinAnnotation.h"

@interface NAInteractiveDemoViewController (){
int _count;
NAPinAnnotation *_lastFocused;
}
@interface NAInteractiveDemoViewController ()
@property (nonatomic, strong) NSMutableArray *annotations;
@property(nonatomic) NAPinAnnotation * lastFocused;
@property (nonatomic, assign) CGSize size;
@property (weak, nonatomic) IBOutlet UILabel *zoomLevelLabel;
@property (weak, nonatomic) IBOutlet UILabel *selectedPinLabel;
Expand All @@ -31,73 +29,70 @@ -(void)viewDidLoad

self.mapView.backgroundColor = [UIColor colorWithRed:0.000f green:0.475f blue:0.761f alpha:1.000f];
self.mapView.mapViewDelegate = self;

[self.mapView displayMap:image];

[self mapView:self.mapView hasChangedZoomLevel:self.mapView.zoomLevel];
self.selectedPinLabel.text = @"";

self.size = image.size;

_count = 0;
_lastFocused = nil;
}

-(IBAction)addPin:(id)sender{

int x = (arc4random() % (int)self.size.width);
int y = (arc4random() % (int)self.size.width);
NSInteger x = (arc4random() % (int)self.size.width);
NSInteger y = (arc4random() % (int)self.size.width);

CGPoint point = CGPointMake(x, y);

[self addPinAt:point withColor:arc4random() % 3];
}

-(void)addPinAt:(CGPoint)point withColor:(NAPinColor)color{

[self.mapView centreOnPoint:point animated:YES];
[self.mapView centerOnPoint:point animated:YES];

NAPinAnnotation *annotation = [NAPinAnnotation annotationWithPoint:point];

annotation.title = [NSString stringWithFormat:@"Pin %d", ++_count];

annotation.title = [NSString stringWithFormat:@"Pin %d", self.annotations.count + 1];
annotation.color = color;

[self.mapView addAnnotation:annotation animated:YES];

[self.annotations addObject:annotation];

_lastFocused = annotation;

}

-(IBAction)removePin:(id)sender{
if(self.annotations.count <= 0 || self.lastFocused == nil) return;
[self.mapView centerOnPoint:self.lastFocused.point animated:YES];
[self.mapView removeAnnotation:self.lastFocused];
[self.annotations removeObject:self.lastFocused];
self.lastFocused = self.annotations.lastObject;
}

if([self.annotations count] <= 0 || _lastFocused == nil) return;

[self.mapView centreOnPoint:_lastFocused.point animated:YES];
-(IBAction)selectRandom:(id)sender{
if(self.annotations.count <= 0) return;

[self.mapView removeAnnotation:_lastFocused];
NSInteger rand = (arc4random() % (int)self.annotations.count);

[self.annotations removeObject:_lastFocused];
NAPinAnnotation *annotation = [self.annotations objectAtIndex:rand];
if (annotation == self.lastFocused && self.annotations.count > 1) {
rand = ((rand + 1) % (int)self.annotations.count);
annotation = [self.annotations objectAtIndex:rand];
}

_lastFocused = ([self.annotations count] > 0) ? [self.annotations objectAtIndex:[self.annotations count]-1] : nil;
[self selectPin:annotation];
}

-(IBAction)selectRandom:(id)sender{
if([self.annotations count] <= 0) return;

int rand = (arc4random() % (int)[self.annotations count]);
[self selectPinAt:rand];
-(void)selectPinAt:(NSInteger)index
{
[self selectPin:[self.annotations objectAtIndex:index]];
}

-(void)selectPinAt:(NSInteger)index{
NAPinAnnotation *annotation = [self.annotations objectAtIndex:index];

-(void)selectPin:(NAPinAnnotation *)annotation
{
self.selectedPinLabel.text = [NSString stringWithFormat:@"%@", annotation.title];

[self.mapView selectAnnotation:annotation animated:YES];

_lastFocused = annotation;
}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NALoadViaNIBDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NALoadViaNIBDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NALoadViaNIBDemoViewController.h"
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NAMasterViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
10 changes: 5 additions & 5 deletions Demo/Demo/NAMasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAMasterViewController.h"
Expand All @@ -24,7 +24,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
}
return self;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
Expand All @@ -44,13 +44,13 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Simple Annotations Demo";
Expand All @@ -74,7 +74,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textLabel.text = @"???";
break;
}

return cell;
}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NAPinAnnotationsDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
4 changes: 2 additions & 2 deletions Demo/Demo/NAPinAnnotationsDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Neil Ang on 6/05/12.
// Copyright (c) 2012 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAPinAnnotationsDemoViewController.h"
Expand Down Expand Up @@ -43,7 +43,7 @@ - (void)viewDidLoad
perth.color = NAPinColorRed;

[mapView addAnnotation:perth animated:YES];

NAPinAnnotation * brisbane = [NAPinAnnotation annotationWithPoint:CGPointMake(679.0f, 302.0f)];
brisbane.title = @"Brisbane";
brisbane.color = NAPinColorPurple;
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NATiledImageDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// NATiledImageDemoViewController.h
//
// Created by Daniel Doubrovkine on 3/10/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
11 changes: 6 additions & 5 deletions Demo/Demo/NATiledImageDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Daniel Doubrovkine on 3/10/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NATiledImageDemoViewController.h"
Expand All @@ -19,7 +19,7 @@ @implementation NATiledImageDemoViewController
-(void)viewDidLoad
{
[super viewDidLoad];

NADZTileImageDataSource *dzTileImageDataSource = [[NADZTileImageDataSource alloc] init];
dzTileImageDataSource.maxTiledHeight = 5389;
dzTileImageDataSource.maxTiledWidth = 5000;
Expand All @@ -28,16 +28,17 @@ -(void)viewDidLoad
dzTileImageDataSource.tileSize = 512;
dzTileImageDataSource.tileFormat = @"jpg";
dzTileImageDataSource.tileBaseURL = [NSURL URLWithString:@"https://raw.github.com/dblock/NAMapKit/tiled-map-view/Demo/Maps/Armory2014/tiles"];

NATiledImageMapView *mapView = [[NATiledImageMapView alloc] initWithFrame:self.view.bounds tiledImageDataSource:dzTileImageDataSource];
mapView.backgroundColor = [UIColor colorWithRed:0.000f green:0.475f blue:0.761f alpha:1.000f];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// mapView.displayTileBorders = YES;
mapView.backgroundImageURL = [NSURL URLWithString:@"https://raw.github.com/dblock/NAMapKit/tiled-map-view/Demo/Maps/Armory2014/large.jpg"];
mapView.zoomStep = 3.0f;
_mapView = mapView;

[self.view addSubview:mapView];

NAAnnotation *champagneBar = [NAAnnotation annotationWithPoint:[mapView coordinateFor:CGPointMake(0.30f, 0.10f)]];
[mapView addAnnotation:champagneBar animated:NO];

Expand Down
2 changes: 1 addition & 1 deletion Demo/DemoTests/NAAnnotationDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Daniel Doubrovkine on 3/8/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAAnnotationDemoViewController.h"
Expand Down
2 changes: 1 addition & 1 deletion Demo/DemoTests/NAInteractiveDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Demo
//
// Created by Daniel Doubrovkine on 3/7/14.
// Copyright (c) 2014 neilang.com. All rights reserved.
// Copyright (c) 2010-14 neilang.com. All rights reserved.
//

#import "NAInteractiveDemoViewController.h"
Expand Down
Loading