diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-10-01 17:58:08 -0700 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-10-02 11:50:53 -0700 |
commit | 8cc3b12f1e8b47ecc930e8c4bb683ac1a57788eb (patch) | |
tree | 6f955bcfd7682b48e6a96935c1ff9a50983c86ca /ios/app | |
parent | ddc4a8193e775d9cd9280ad7d9bb6975b4a323ee (diff) | |
download | qtlocation-mapboxgl-8cc3b12f1e8b47ecc930e8c4bb683ac1a57788eb.tar.gz |
[ios] fixes #2490: add annotation image enabled property
Diffstat (limited to 'ios/app')
-rw-r--r-- | ios/app/MBXViewController.mm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index bb35a07910..d05d142a52 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -357,6 +357,15 @@ static NSUInteger const kStyleVersion = 8; NSString *title = [(MGLPointAnnotation *)annotation title]; NSString *lastTwoCharacters = [title substringFromIndex:title.length - 2]; + UIColor *color; + + // make every tenth annotation blue + if ([lastTwoCharacters hasSuffix:@"0"]) { + color = [UIColor blueColor]; + } else { + color = [UIColor redColor]; + } + MGLAnnotationImage *image = [mapView dequeueReusableAnnotationImageWithIdentifier:lastTwoCharacters]; if ( ! image) @@ -367,7 +376,7 @@ static NSUInteger const kStyleVersion = 8; CGContextRef ctx = UIGraphicsGetCurrentContext(); - CGContextSetFillColorWithColor(ctx, [[[UIColor redColor] colorWithAlphaComponent:0.75] CGColor]); + CGContextSetFillColorWithColor(ctx, [[color colorWithAlphaComponent:0.75] CGColor]); CGContextFillRect(ctx, rect); CGContextSetStrokeColorWithColor(ctx, [[UIColor blackColor] CGColor]); @@ -385,6 +394,9 @@ static NSUInteger const kStyleVersion = 8; image = [MGLAnnotationImage annotationImageWithImage:UIGraphicsGetImageFromCurrentImageContext() reuseIdentifier:lastTwoCharacters]; + // don't allow touches on blue annotations + if ([color isEqual:[UIColor blueColor]]) image.enabled = NO; + UIGraphicsEndImageContext(); } |