summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2016-07-25 11:41:06 -0700
committerJustin R. Miller <incanus@codesorcery.net>2016-07-25 17:11:14 -0700
commit8cfaac11fdd49b869144fb51d1a591034d01c471 (patch)
treed10dc212356e71dad3b423e02189f4cabf6f416d /platform
parentde197ca9e57282b294f574ea6fbfc8867a651c01 (diff)
downloadqtlocation-mapboxgl-8cfaac11fdd49b869144fb51d1a591034d01c471.tar.gz
use class instead of magic string comparison
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/app/MBXViewController.m17
1 files changed, 10 insertions, 7 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 0b793206d3..5176692e1d 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -30,6 +30,12 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
@implementation MBXCustomCalloutAnnotation
@end
+@interface MBXSpriteBackedAnnotation : MGLPointAnnotation
+@end
+
+@implementation MBXSpriteBackedAnnotation
+@end
+
@interface MBXViewController () <UIActionSheetDelegate, MGLMapViewDelegate>
@property (nonatomic) IBOutlet MGLMapView *mapView;
@@ -313,10 +319,10 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
[feature[@"geometry"][@"coordinates"][0] doubleValue]);
NSString *title = feature[@"properties"][@"NAME"];
- MGLPointAnnotation *annotation = [MGLPointAnnotation new];
+ MGLPointAnnotation *annotation = (useViews ? [MGLPointAnnotation new] : [MBXSpriteBackedAnnotation new]);
+
annotation.coordinate = coordinate;
annotation.title = title;
- annotation.subtitle = [NSString stringWithFormat:@"View: %i", useViews];
[annotations addObject:annotation];
@@ -598,8 +604,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
- (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation
{
// Use GL backed pins for dropped pin annotations
- if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]] ||
- ([annotation isKindOfClass:[MGLPointAnnotation class]] && [[(MGLPointAnnotation *)annotation subtitle] isEqualToString:@"View: 0"]))
+ if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]] || [annotation isKindOfClass:[MBXSpriteBackedAnnotation class]])
{
return nil;
}
@@ -629,9 +634,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
- (MGLAnnotationImage *)mapView:(MGLMapView * __nonnull)mapView imageForAnnotation:(id <MGLAnnotation> __nonnull)annotation
{
- if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]] ||
- [annotation isKindOfClass:[MBXCustomCalloutAnnotation class]] ||
- ([annotation isKindOfClass:[MGLPointAnnotation class]] && [[(MGLPointAnnotation *)annotation subtitle] isEqualToString:@"View: 1"]))
+ if ([annotation isKindOfClass:[MBXDroppedPinAnnotation class]] || [annotation isKindOfClass:[MBXCustomCalloutAnnotation class]])
{
return nil; // use default marker
}