Skip to content

Commit

Permalink
Merge pull request #18 from dblock/refactored-map-kit
Browse files Browse the repository at this point in the history
Use released versions of FBSnapshotTestCase, added delegate support and cleaned up deprecations.
  • Loading branch information
neilang committed Mar 11, 2014
2 parents 71944e4 + 7362252 commit f19e658
Show file tree
Hide file tree
Showing 26 changed files with 213 additions and 401 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#### [3.0](https://github.com/neilang/NAMapKit/tree/version-3.0) (Next)

* [#16](https://github.com/neilang/NAMapKit/pull/16) - Extracted `NAPinAnnotationMapView` out of a, now mimimal, `NAMapView` - [@dblock](github.com/dblock).
* [#18](https://github.com/neilang/NAMapKit/pull/18) - Added `NAMapViewDelegate` for easier handling of taps and zoom events - [@dblock](github.com/dblock).

#### [HEAD](https://github.com/neilang/NAMapKit) (Stable)

Expand Down
3 changes: 2 additions & 1 deletion Demo/Demo/NAAnnotationDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//

#import <UIKit/UIKit.h>
#import "NAMapViewDelegate.h"

@interface NAAnnotationDemoViewController : UIViewController
@interface NAAnnotationDemoViewController : UIViewController<NAMapViewDelegate>

@end
13 changes: 12 additions & 1 deletion Demo/Demo/NAAnnotationDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ - (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 All @@ -42,4 +43,14 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)mapView:(NAMapView *)mapView tappedOnAnnotation:(NAAnnotation *)annotation
{
NSLog(@"tapped: %@", annotation);
}

- (void)mapView:(NAMapView *)mapView hasChangedZoomLevel:(CGFloat)level
{
NSLog(@"zoom: %@", @(level));
}

@end
2 changes: 1 addition & 1 deletion Demo/Demo/NAInteractiveDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "NAMapView.h"
#import "NAPinAnnotation.h"

@interface NAInteractiveDemoViewController : UIViewController
@interface NAInteractiveDemoViewController : UIViewController<NAMapViewDelegate>

@property (nonatomic, weak) IBOutlet NAMapView *mapView;

Expand Down
25 changes: 21 additions & 4 deletions Demo/Demo/NAInteractiveDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ @interface NAInteractiveDemoViewController (){
}
@property (nonatomic, strong) NSMutableArray *annotations;
@property (nonatomic, assign) CGSize size;

@property (weak, nonatomic) IBOutlet UILabel *zoomLevelLabel;
@property (weak, nonatomic) IBOutlet UILabel *selectedPinLabel;
@end

@implementation NAInteractiveDemoViewController

- (void)viewDidLoad
-(void)viewDidLoad
{
[super viewDidLoad];

Expand All @@ -29,9 +30,13 @@ - (void)viewDidLoad
UIImage *image = [UIImage imageNamed:@"australia"];

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;
Expand Down Expand Up @@ -88,10 +93,22 @@ -(IBAction)selectRandom:(id)sender{

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


self.selectedPinLabel.text = [NSString stringWithFormat:@"%@", annotation.title];

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

_lastFocused = annotation;
}

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

- (void)mapView:(NAMapView *)mapView hasChangedZoomLevel:(CGFloat)level
{
self.zoomLevelLabel.text = [NSString stringWithFormat:@"%.2f", level];
}

@end
Loading

0 comments on commit f19e658

Please sign in to comment.