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 1/5] 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); From 4de7f89f47ba286b00cc3510f07b1cceb3a3c57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 10 May 2015 04:19:01 -0700 Subject: [PATCH 2/5] Turned copyright notices into action buttons --- platform/ios/MGLMapView.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index c7bceb1c7..49ed42346 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1255,12 +1255,13 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) - (void)showAttribution { - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"© Mapbox © OpenStreetMap" + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox GL for iOS" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: - @"About This Map", + @"© Mapbox", + @"© OpenStreetMap", @"Improve This Map", nil]; [sheet showFromRect:self.attributionButton.frame inView:self animated:YES]; @@ -1274,6 +1275,11 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) [NSURL URLWithString:@"https://www.mapbox.com/about/maps/"]]; } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) + { + [[UIApplication sharedApplication] openURL: + [NSURL URLWithString:@"http://www.openstreetmap.org/about/"]]; + } + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2) { [[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"https://www.mapbox.com/map-feedback/"]]; From fbafa153950cd853517418ea13a411ffc918d3a4 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sun, 10 May 2015 23:14:16 -0700 Subject: [PATCH 3/5] Add long/lat/zoom to feedback URL --- platform/ios/MGLMapView.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 49ed42346..c1ff904cb 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1281,8 +1281,10 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2) { + NSString *feedbackURL = [NSString stringWithFormat:@"https://www.mapbox.com/map-feedback/#/%.5f/%.5f/%.1f", + self.longitude, self.latitude, self.zoomLevel]; [[UIApplication sharedApplication] openURL: - [NSURL URLWithString:@"https://www.mapbox.com/map-feedback/"]]; + [NSURL URLWithString:feedbackURL]]; } } From 7da7f65579fae412fea0fecd9afc3b56e4577ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 10 May 2015 23:32:38 -0700 Subject: [PATCH 4/5] Dismiss attribution popover on rotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Constraints go invalid when rotating an iPad while the popover is visible and anchored to the ℹ️. --- platform/ios/MGLMapView.mm | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index c1ff904cb..5c7e6ad61 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -63,6 +63,7 @@ static NSURL *MGLURLForBundledStyleNamed(NSString *styleName) @property (nonatomic) UIImageView *compass; @property (nonatomic) UIImageView *logoBug; @property (nonatomic) UIButton *attributionButton; +@property (nonatomic) UIActionSheet *attributionSheet; @property (nonatomic) UIPanGestureRecognizer *pan; @property (nonatomic) UIPinchGestureRecognizer *pinch; @property (nonatomic) UIRotationGestureRecognizer *rotate; @@ -306,6 +307,16 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) [_attributionButton addTarget:self action:@selector(showAttribution) forControlEvents:UIControlEventTouchUpInside]; _attributionButton.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:_attributionButton]; + + _attributionSheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox GL for iOS" + delegate:self + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:nil + otherButtonTitles: + @"© Mapbox", + @"© OpenStreetMap", + @"Improve This Map", + nil]; // setup compass // @@ -647,6 +658,11 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) { _mbglMap->update(); } + + if (self.attributionSheet.visible) + { + [self.attributionSheet dismissWithClickedButtonIndex:self.attributionSheet.cancelButtonIndex animated:YES]; + } } #pragma mark - Life Cycle - @@ -1255,16 +1271,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) - (void)showAttribution { - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox GL for iOS" - delegate:self - cancelButtonTitle:@"Cancel" - destructiveButtonTitle:nil - otherButtonTitles: - @"© Mapbox", - @"© OpenStreetMap", - @"Improve This Map", - nil]; - [sheet showFromRect:self.attributionButton.frame inView:self animated:YES]; + [self.attributionSheet showFromRect:self.attributionButton.frame inView:self animated:YES]; } - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex From 965bc41d438e99fc85b036b5786b471898d33e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 10 May 2015 23:34:47 -0700 Subject: [PATCH 5/5] Round zoom level for Map Feedback tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Map Feedback tool is still using mapbox.js, so it doesn’t support fractional zoom levels yet. --- platform/ios/MGLMapView.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 5c7e6ad61..b6ae9eb99 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1288,8 +1288,8 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2) { - NSString *feedbackURL = [NSString stringWithFormat:@"https://www.mapbox.com/map-feedback/#/%.5f/%.5f/%.1f", - self.longitude, self.latitude, self.zoomLevel]; + NSString *feedbackURL = [NSString stringWithFormat:@"https://www.mapbox.com/map-feedback/#/%.5f/%.5f/%i", + self.longitude, self.latitude, (int)round(self.zoomLevel)]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString:feedbackURL]]; }