From 965f90c449bc607caa7a34ebf0f762fdfb01417a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 10 May 2015 03:53:24 -0700 Subject: [PATCH] Attribute Mapbox and OpenStreetMap in-app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ℹ️ now pops up an action sheet with explicit attribution and a direct link to the Map Feedback tool. --- platform/ios/MGLMapView.mm | 43 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 7488c366d..c7bceb1c7 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -54,7 +54,7 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName) #pragma mark - Private - -@interface MGLMapView () +@interface MGLMapView () @property (nonatomic) EAGLContext *context; @property (nonatomic) GLKView *glView; @@ -303,7 +303,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) // _attributionButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; _attributionButton.accessibilityLabel = @"Attribution info"; - [_attributionButton addTarget:self action:@selector(showAttribution:) forControlEvents:UIControlEventTouchUpInside]; + [_attributionButton addTarget:self action:@selector(showAttribution) forControlEvents:UIControlEventTouchUpInside]; _attributionButton.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:_attributionButton]; @@ -1251,6 +1251,35 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) }]; } +#pragma mark - Attribution - + +- (void)showAttribution +{ + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"© Mapbox © OpenStreetMap" + delegate:self + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:nil + otherButtonTitles: + @"About This Map", + @"Improve This Map", + nil]; + [sheet showFromRect:self.attributionButton.frame inView:self animated:YES]; +} + +- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex +{ + if (buttonIndex == actionSheet.firstOtherButtonIndex) + { + [[UIApplication sharedApplication] openURL: + [NSURL URLWithString:@"https://www.mapbox.com/about/maps/"]]; + } + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) + { + [[UIApplication sharedApplication] openURL: + [NSURL URLWithString:@"https://www.mapbox.com/map-feedback/"]]; + } +} + #pragma mark - Properties - + (NSSet *)keyPathsForValuesAffectingZoomEnabled @@ -1268,16 +1297,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) return [NSSet setWithObject:@"allowsRotating"]; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" - -- (void)showAttribution:(id)sender -{ - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.mapbox.com/about/maps/"]]; -} - -#pragma clang diagnostic pop - - (void)setDebugActive:(BOOL)debugActive { _mbglMap->setDebug(debugActive);