diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLCalloutView.h | 6 | ||||
-rw-r--r-- | platform/ios/src/MGLCalloutView.m | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLCompactCalloutView.h | 11 | ||||
-rw-r--r-- | platform/ios/src/MGLCompactCalloutView.m | 31 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 21 |
5 files changed, 51 insertions, 23 deletions
diff --git a/platform/ios/src/MGLCalloutView.h b/platform/ios/src/MGLCalloutView.h deleted file mode 100644 index aa5cb95b57..0000000000 --- a/platform/ios/src/MGLCalloutView.h +++ /dev/null @@ -1,6 +0,0 @@ -#import "SMCalloutView.h" -#import "MGLCalloutViewProtocol.h" - -@interface MGLCalloutView : SMCalloutView <MGLCalloutViewProtocol> - -@end diff --git a/platform/ios/src/MGLCalloutView.m b/platform/ios/src/MGLCalloutView.m deleted file mode 100644 index 8fc7cdc08d..0000000000 --- a/platform/ios/src/MGLCalloutView.m +++ /dev/null @@ -1,5 +0,0 @@ -#import "MGLCalloutView.h" - -@implementation MGLCalloutView - -@end diff --git a/platform/ios/src/MGLCompactCalloutView.h b/platform/ios/src/MGLCompactCalloutView.h new file mode 100644 index 0000000000..5f8edd921f --- /dev/null +++ b/platform/ios/src/MGLCompactCalloutView.h @@ -0,0 +1,11 @@ +#import "SMCalloutView.h" +#import "MGLCalloutView.h" + +/** + A concrete implementation of `MGLCalloutView` based on [SMCalloutView](https://github.com/nfarina/calloutview). This callout view displays the represented annotation’s title, subtitle, and accessory views in a compact, two-line layout. + */ +@interface MGLCompactCalloutView : SMCalloutView <MGLCalloutView> + ++ (instancetype)platformCalloutView; + +@end diff --git a/platform/ios/src/MGLCompactCalloutView.m b/platform/ios/src/MGLCompactCalloutView.m new file mode 100644 index 0000000000..49812c51a4 --- /dev/null +++ b/platform/ios/src/MGLCompactCalloutView.m @@ -0,0 +1,31 @@ +#import "MGLCompactCalloutView.h" + +#import "MGLAnnotation.h" + +@implementation MGLCompactCalloutView +{ + id <MGLAnnotation> _representedObject; +} + +@synthesize representedObject = _representedObject; + ++ (instancetype)platformCalloutView +{ + return [[self alloc] init]; +} + +- (void)setRepresentedObject:(id <MGLAnnotation>)representedObject +{ + _representedObject = representedObject; + + if ([representedObject respondsToSelector:@selector(title)]) + { + self.title = representedObject.title; + } + if ([representedObject respondsToSelector:@selector(subtitle)]) + { + self.subtitle = representedObject.subtitle; + } +} + +@end diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index ce42fefe3f..c0909f873d 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -39,7 +39,7 @@ #import "MGLAccountManager_Private.h" #import "MGLAnnotationImage_Private.h" #import "MGLMapboxEvents.h" -#import "MGLCalloutView.h" +#import "MGLCompactCalloutView.h" #import <algorithm> #import <cstdlib> @@ -138,7 +138,7 @@ public: /// Mapping from reusable identifiers to annotation images. @property (nonatomic) NS_MUTABLE_DICTIONARY_OF(NSString *, MGLAnnotationImage *) *annotationImagesByIdentifier; /// Currently shown popover representing the selected annotation. -@property (nonatomic) UIView<MGLCalloutViewProtocol> *calloutViewForSelectedAnnotation; +@property (nonatomic) UIView<MGLCalloutView> *calloutViewForSelectedAnnotation; @property (nonatomic) MGLUserLocationAnnotationView *userLocationAnnotationView; @property (nonatomic) CLLocationManager *locationManager; @property (nonatomic) CGPoint centerPoint; @@ -1341,12 +1341,12 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) } } -- (BOOL)calloutViewShouldHighlight:(__unused MGLCalloutView *)calloutView +- (BOOL)calloutViewShouldHighlight:(__unused MGLCompactCalloutView *)calloutView { return [self.delegate respondsToSelector:@selector(mapView:tapOnCalloutForAnnotation:)]; } -- (void)calloutViewClicked:(__unused MGLCalloutView *)calloutView +- (void)calloutViewTapped:(__unused MGLCompactCalloutView *)calloutView { if ([self.delegate respondsToSelector:@selector(mapView:tapOnCalloutForAnnotation:)]) { @@ -2514,9 +2514,9 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) [self.delegate mapView:self annotationCanShowCallout:annotation]) { // build the callout - if ([self.delegate respondsToSelector:@selector(mapView:customCalloutViewForAnnotation:)]) + if ([self.delegate respondsToSelector:@selector(mapView:calloutViewForAnnotation:)]) { - self.calloutViewForSelectedAnnotation = [self.delegate mapView:self customCalloutViewForAnnotation:annotation]; + self.calloutViewForSelectedAnnotation = [self.delegate mapView:self calloutViewForAnnotation:annotation]; } if (!self.calloutViewForSelectedAnnotation) { @@ -2576,13 +2576,10 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) } } -- (MGLCalloutView *)calloutViewForAnnotation:(id <MGLAnnotation>)annotation +- (MGLCompactCalloutView *)calloutViewForAnnotation:(id <MGLAnnotation>)annotation { - MGLCalloutView *calloutView = (MGLCalloutView *)[MGLCalloutView platformCalloutView]; - - if ([annotation respondsToSelector:@selector(title)]) calloutView.title = annotation.title; - if ([annotation respondsToSelector:@selector(subtitle)]) calloutView.subtitle = annotation.subtitle; - + MGLCompactCalloutView *calloutView = [MGLCompactCalloutView platformCalloutView]; + calloutView.representedObject = annotation; calloutView.tintColor = self.tintColor; return calloutView; |