[ios] fixes #5544 support canceling a drag operation and not by default (#5561)

This commit is contained in:
Fredrik Karlsson
2016-07-05 22:47:54 +02:00
committed by GitHub
parent 546469459f
commit 7b6ef80b5d
4 changed files with 12 additions and 34 deletions

View File

@@ -212,13 +212,21 @@
[self.mapView.calloutViewForSelectedAnnotation dismissCalloutAnimated:animated];
[self.superview bringSubviewToFront:self];
}
if (dragState == MGLAnnotationViewDragStateEnding)
else if (dragState == MGLAnnotationViewDragStateCanceling)
{
if ([self.mapView.delegate respondsToSelector:@selector(mapView:didDragAnnotationView:toCoordinate:)])
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.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"];
}
}
}