Gestures
The AMap iOS SDK provides a rich set of gesture controls for map interaction. You can enable or disable these gestures by modifying the corresponding properties of MAMapView.
Gesture Overview
The following table lists the available gesture controls:
Zoom Gesture
The zoom gesture changes the map's zoom level. The map responds to the following interactions:
- Double-tap to zoom in by one level.
- Pinch with two fingers to zoom in or out.
Use the zoomEnabled property of MAMapView to disable or enable the zoom gesture. Disabling this gesture does not affect the zoom controls on the map.
_mapView.zoomEnabled = NO; // NO disables zoom, YES enables itSetting the Zoom Level
The zoom level ranges from 3 to 19. Call the setZoomLevel:animated: method on MAMapView to programmatically set the zoom level.
[_mapView setZoomLevel:17.5 animated:YES];Scroll Gesture
The scroll gesture allows you to drag or swipe the map to pan across the view.
Use the scrollEnabled property of MAMapView to disable or enable the scroll gesture.
_mapView.scrollEnabled = NO; // NO disables scrolling, YES enables itSetting the Center Coordinate
When panning the map, the zoom level remains unchanged. You can move the map by changing its center coordinate.
[_mapView setCenterCoordinate:center animated:YES];Rotation Gesture
The rotation gesture lets you rotate the 3D vector map by turning two fingers on the screen.
Use the rotateEnabled property of MAMapView to disable or enable the rotation gesture.
_mapView.rotateEnabled = NO; // NO disables rotation, YES enables itSetting the Rotation Angle
The rotation angle ranges from 0.0 to 360.0 degrees, with counter-clockwise as the positive direction. Call the setRotationDegree:animated: method on MAMapView to set the rotation angle.
[_mapView setRotationDegree:60.f animated:YES duration:0.5];Tilt Gesture
The tilt gesture allows you to increase or decrease the camera pitch angle by moving two fingers up or down on the screen.
Use the rotateCameraEnabled property of MAMapView to disable or enable the tilt gesture.
_mapView.rotateCameraEnabled = NO; // NO disables tilt, YES enables itSetting the Tilt Angle
The tilt angle ranges from 0.0 to 45.0 degrees. Call the setCameraDegree:animated: method on MAMapView to set the tilt angle.
[_mapView setCameraDegree:30.f animated:YES duration:0.5]; Gesture Operations with a Specified Screen Center
For gesture operations (excluding scroll), you can specify a screen center point before performing the gesture. Use the following method to set the screen center:
MAMapStatus *status = [self.mapView getMapStatus];
status.screenAnchor = CGPointMake(0.5, 0.76); // The top-left of the map is (0,0) and the bottom-right is (1,1).
[self.mapView setMapStatus:status animated:NO];