This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pushed annotation class into mgl proper
Split out model object protocol from view object, per MapKit and MVC. Crashes when tapping on a pin. WIP for #894
- Loading branch information
Showing
7 changed files
with
176 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// MGLAnnotation.h | ||
// mbgl | ||
// | ||
// Created by Minh Nguyen on 2015-03-04. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@protocol MGLAnnotation <NSObject> | ||
|
||
//! The receiver’s center, expressed as a coordinate on the containing map. | ||
@property (assign) CLLocationCoordinate2D coordinate; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// MGLAnnotationView.h | ||
// mbgl | ||
// | ||
// Created by Minh Nguyen on 2015-03-04. | ||
// | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class SMCalloutView; | ||
@protocol MGLAnnotation; | ||
|
||
@interface MGLAnnotationView : UIImageView | ||
|
||
@property (nonatomic) id <MGLAnnotation> annotation; | ||
|
||
//! The receiver’s title string. | ||
@property (nonatomic) NSString *title; | ||
|
||
//! The receiver’s subtitle string. | ||
@property (nonatomic) NSString *subtitle; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// MGLAnnotationView.m | ||
// mbgl | ||
// | ||
// Created by Minh Nguyen on 2015-03-04. | ||
// | ||
// | ||
|
||
#import "MGLAnnotationView.h" | ||
|
||
#import "../../calloutview/SMCalloutView.h" | ||
|
||
@interface MGLAnnotationView () | ||
|
||
//! The callout view that pops up when the receiver is selected. | ||
@property (nonatomic) SMCalloutView *calloutView; | ||
|
||
@end | ||
|
||
@implementation MGLAnnotationView | ||
|
||
- (id)initWithCoder:(NSCoder *)aDecoder { | ||
if (self = [super initWithCoder:aDecoder]) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (instancetype)initWithFrame:(CGRect)frame { | ||
if (self = [super initWithFrame:frame]) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (instancetype)initWithImage:(UIImage *)image { | ||
if (self = [super initWithImage:image]) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage { | ||
if (self = [super initWithImage:image highlightedImage:highlightedImage]) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)commonInit { | ||
self.userInteractionEnabled = YES; | ||
self.calloutView = [SMCalloutView platformCalloutView]; | ||
} | ||
|
||
- (void)didMoveToSuperview { | ||
[super didMoveToSuperview]; | ||
|
||
[self.superview addSubview:self.calloutView]; | ||
} | ||
|
||
- (NSString *)title { | ||
return self.calloutView.title; | ||
} | ||
|
||
- (void)setTitle:(NSString *)title { | ||
self.calloutView.title = title; | ||
} | ||
|
||
- (NSSet *)keyPathsForValuesAffectingTitle { | ||
return [NSSet setWithObject:@"calloutview.title"]; | ||
} | ||
|
||
- (NSString *)subtitle { | ||
return self.calloutView.subtitle; | ||
} | ||
|
||
- (void)setSubtitle:(NSString *)subtitle { | ||
self.calloutView.subtitle = subtitle; | ||
} | ||
|
||
- (NSSet *)keyPathsForValuesAffectingSubtitle { | ||
return [NSSet setWithObject:@"calloutview.subtitle"]; | ||
} | ||
|
||
@end |