summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLAnnotationView.mm
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-07-05 22:47:54 +0200
committerGitHub <noreply@github.com>2016-07-05 22:47:54 +0200
commit7b6ef80b5df75d30f7cbb6cedf88e28acbbed288 (patch)
tree625a23d26cfaa8b2697aa0609d8911ca196a0845 /platform/ios/src/MGLAnnotationView.mm
parent546469459fd7a2350cff40fc3e8896fe3581c2f6 (diff)
downloadqtlocation-mapboxgl-7b6ef80b5df75d30f7cbb6cedf88e28acbbed288.tar.gz
[ios] fixes #5544 support canceling a drag operation and not by default (#5561)
Diffstat (limited to 'platform/ios/src/MGLAnnotationView.mm')
-rw-r--r--platform/ios/src/MGLAnnotationView.mm16
1 files changed, 12 insertions, 4 deletions
diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm
index 494253b561..f8591f036b 100644
--- a/platform/ios/src/MGLAnnotationView.mm
+++ b/platform/ios/src/MGLAnnotationView.mm
@@ -212,13 +212,21 @@
[self.mapView.calloutViewForSelectedAnnotation dismissCalloutAnimated:animated];
[self.superview bringSubviewToFront:self];
}
-
- if (dragState == MGLAnnotationViewDragStateEnding)
+ else if (dragState == MGLAnnotationViewDragStateCanceling)
+ {
+ self.panGestureRecognizer.enabled = NO;
+ self.longPressRecognizer.enabled = NO;
+ self.center = [self.mapView convertCoordinate:self.annotation.coordinate toPointToView:self.mapView];
+ self.panGestureRecognizer.enabled = YES;
+ self.longPressRecognizer.enabled = YES;
+ self.dragState = MGLAnnotationViewDragStateNone;
+ }
+ else if (dragState == MGLAnnotationViewDragStateEnding)
{
- if ([self.mapView.delegate respondsToSelector:@selector(mapView:didDragAnnotationView:toCoordinate:)])
+ if ([self.annotation respondsToSelector:@selector(setCoordinate:)])
{
CLLocationCoordinate2D coordinate = [self.mapView convertPoint:self.center toCoordinateFromView:self.mapView];
- [self.mapView.delegate mapView:self.mapView didDragAnnotationView:self toCoordinate:coordinate];
+ [(NSObject *)self.annotation setValue:[NSValue valueWithMGLCoordinate:coordinate] forKey:@"coordinate"];
}
}
}