summaryrefslogtreecommitdiff
path: root/platform/ios/app
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/app')
-rw-r--r--platform/ios/app/MBXAnnotationView.m36
-rw-r--r--platform/ios/app/MBXViewController.m14
2 files changed, 50 insertions, 0 deletions
diff --git a/platform/ios/app/MBXAnnotationView.m b/platform/ios/app/MBXAnnotationView.m
index 890881a316..c181211431 100644
--- a/platform/ios/app/MBXAnnotationView.m
+++ b/platform/ios/app/MBXAnnotationView.m
@@ -25,4 +25,40 @@
}
}
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated
+{
+ [super setSelected:selected animated:animated];
+
+ self.layer.borderColor = selected ? [UIColor blackColor].CGColor : [UIColor whiteColor].CGColor;
+ self.layer.borderWidth = selected ? 2.0 : 0;
+}
+
+- (void)setDragState:(MGLAnnotationViewDragState)dragState animated:(BOOL)animated
+{
+ [super setDragState:dragState animated:NO];
+
+ switch (dragState) {
+ case MGLAnnotationViewDragStateNone:
+ break;
+ case MGLAnnotationViewDragStateStarting: {
+ [UIView animateWithDuration:.4 delay:0 usingSpringWithDamping:.4 initialSpringVelocity:.5 options:UIViewAnimationOptionCurveLinear animations:^{
+ self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2);
+ } completion:nil];
+ break;
+ }
+ case MGLAnnotationViewDragStateDragging:
+ break;
+ case MGLAnnotationViewDragStateCanceling:
+ break;
+ case MGLAnnotationViewDragStateEnding: {
+ [UIView animateWithDuration:.4 delay:0 usingSpringWithDamping:.4 initialSpringVelocity:.5 options:UIViewAnimationOptionCurveLinear animations:^{
+ self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1);
+ } completion:nil];
+ break;
+ }
+ }
+
+}
+
+
@end
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 761644b29f..cd5694d835 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -411,6 +411,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
{
if (longPress.state == UIGestureRecognizerStateBegan)
{
+ /*
CGPoint point = [longPress locationInView:longPress.view];
NSArray *features = [self.mapView visibleFeaturesAtPoint:point];
NSString *title;
@@ -427,6 +428,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
pin.subtitle = [[[MGLCoordinateFormatter alloc] init] stringFromCoordinate:pin.coordinate];
// Calling `addAnnotation:` on mapView is not required since `selectAnnotation:animated` has the side effect of adding the annotation if required
[self.mapView selectAnnotation:pin animated:YES];
+ */
}
}
@@ -590,6 +592,12 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
// uncomment to flatten the annotation view against the map when the map is tilted
// this currently causes severe performance issues when more than 2k annotations are visible
// annotationView.flat = YES;
+
+ // uncomment to make the annotation view draggable
+ // also note that having two long press gesture recognizers on overlapping views (`self.view` & `annotationView`) will cause weird behaviour
+ // comment out the pin dropping functionality in the handleLongPress: method in this class to make draggable annotation views play nice
+ annotationView.draggable = YES;
+
// uncomment to force annotation view to maintain a constant size when the map is tilted
// by default, annotation views will shrink and grow as the move towards and away from the
@@ -603,6 +611,12 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
return annotationView;
}
+- (void)mapView:(MGLMapView *)mapView didDragAnnotationView:(nonnull MGLAnnotationView *)annotationView toCoordinate:(CLLocationCoordinate2D)coordinate
+{
+ MGLPointAnnotation *annotation = (MGLPointAnnotation *)annotationView.annotation;
+ annotation.coordinate = coordinate;
+}
+
- (BOOL)mapView:(__unused MGLMapView *)mapView annotationCanShowCallout:(__unused id <MGLAnnotation>)annotation
{
return YES;