diff options
author | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2016-07-05 22:47:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-05 22:47:54 +0200 |
commit | 7b6ef80b5df75d30f7cbb6cedf88e28acbbed288 (patch) | |
tree | 625a23d26cfaa8b2697aa0609d8911ca196a0845 /platform/ios/src | |
parent | 546469459fd7a2350cff40fc3e8896fe3581c2f6 (diff) | |
download | qtlocation-mapboxgl-7b6ef80b5df75d30f7cbb6cedf88e28acbbed288.tar.gz |
[ios] fixes #5544 support canceling a drag operation and not by default (#5561)
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLAnnotationView.h | 3 | ||||
-rw-r--r-- | platform/ios/src/MGLAnnotationView.mm | 16 | ||||
-rw-r--r-- | platform/ios/src/MGLMapViewDelegate.h | 21 |
3 files changed, 12 insertions, 28 deletions
diff --git a/platform/ios/src/MGLAnnotationView.h b/platform/ios/src/MGLAnnotationView.h index ff23cbefb7..622c31c7b3 100644 --- a/platform/ios/src/MGLAnnotationView.h +++ b/platform/ios/src/MGLAnnotationView.h @@ -202,9 +202,6 @@ typedef NS_ENUM(NSUInteger, MGLAnnotationViewDragState) { attempting to stop an operation that has already been initiated; doing so can lead to undefined behavior. Once begun, the drag operation should always continue to completion. - - `-mapView:didDragAnnotationView:toCoordinate:` is called when a view is - dropped. */ @property (nonatomic, assign, getter=isDraggable) BOOL draggable; 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"]; } } } diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h index c117c5d159..12a0658a51 100644 --- a/platform/ios/src/MGLMapViewDelegate.h +++ b/platform/ios/src/MGLMapViewDelegate.h @@ -284,27 +284,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)mapView:(MGLMapView *)mapView didAddAnnotationViews:(NS_ARRAY_OF(MGLAnnotationView *) *)annotationViews; -#pragma mark Dragging Annotation Views - -/** - Tells the delegate that the user has dragged the given annotation view to a new - location. - - This method is called as soon as the user finishes dragging and drops the - annotation view at a new location. - - To permanently move the corresponding annotation to the new geographic - coordinate, set the annotation’s `coordinate` property to the given coordinate. - Otherwise, the annotation view will return to the original location - corresponding to that property’s value. - - @param mapView The map view containing the annotation view. - @param annotationView The annotation view that was dragged. - @param coordinate The geographic coordinate corresponding to the location to - which the user has dragged the annotation view. - */ -- (void)mapView:(MGLMapView *)mapView didDragAnnotationView:(MGLAnnotationView *)annotationView toCoordinate:(CLLocationCoordinate2D)coordinate; - #pragma mark Selecting Annotations /** |