summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-10-13 17:53:13 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-10-15 11:33:58 -0700
commit6e1b1836f472dee2a57cf11766eb1a04a11ad40a (patch)
tree33057639d638c179960cc4b4e32e5e106facb819 /ios
parent074d61a55e32e83173ec12b2eb34b78ddaaf0ef1 (diff)
downloadqtlocation-mapboxgl-6e1b1836f472dee2a57cf11766eb1a04a11ad40a.tar.gz
fixes #2611: iOS test app long press drops debug marker
Diffstat (limited to 'ios')
-rw-r--r--ios/app/MBXViewController.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index d05d142a52..302efbe9fc 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -82,6 +82,8 @@ static NSUInteger const kStyleVersion = 8;
target:self
action:@selector(locateUser)];
+ [self.mapView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]];
+
[self restoreState:nil];
}
@@ -296,6 +298,20 @@ static NSUInteger const kStyleVersion = 8;
});
}
+- (void)handleLongPress:(UILongPressGestureRecognizer *)longPress
+{
+ if (longPress.state == UIGestureRecognizerStateBegan)
+ {
+ MGLPointAnnotation *point = [MGLPointAnnotation new];
+ point.coordinate = [self.mapView convertPoint:[longPress locationInView:longPress.view]
+ toCoordinateFromView:self.mapView];
+ point.title = @"Dropped Marker";
+ point.subtitle = [NSString stringWithFormat:@"lat: %.3f, lon: %.3f", point.coordinate.latitude, point.coordinate.longitude];
+ [self.mapView addAnnotation:point];
+ [self.mapView selectAnnotation:point animated:YES];
+ }
+}
+
- (void)cycleStyles
{
UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
@@ -354,6 +370,8 @@ static NSUInteger const kStyleVersion = 8;
- (MGLAnnotationImage *)mapView:(MGLMapView * __nonnull)mapView imageForAnnotation:(id <MGLAnnotation> __nonnull)annotation
{
+ if ([annotation.title isEqualToString:@"Dropped Marker"]) return nil; // use default marker
+
NSString *title = [(MGLPointAnnotation *)annotation title];
NSString *lastTwoCharacters = [title substringFromIndex:title.length - 2];