iOS Google map - How to know when user begins or stop drag map
To detect if the user dragged the map I think it's better to use this delegate method
Obj-C
- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture
Swift
func mapView(_ mapView: GMSMapView, willMove gesture: Bool)
and check whether gesture
argument is true
or not.
The didChangeCameraPosition
is called, as mentioned, many times but since it's also called by both setting the map center from code and as a result of a gesture you can't really see the difference in that method alone.
Swift 4:
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) { if (gesture){ print("dragged") }}
From the documentation :
- (void) mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position
Called when the map becomes idle, after any outstanding gestures or animations have completed (or after the camera has been explicitly set).
So with this delegate you can capture when the user stopped dragging the mapView.
To get notified when the user did start dragging, just use the other delegate you have pointed out:
- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position
Called repeatedly during any animations or gestures on the map (or once, if the camera is explicitly set).
This may not be called for all intermediate camera positions. It is always called for the final position of an animation or gesture.
I'm not sure what is confusing you.