SDK for iOS Developer's Guide

Map Gestures

The NMAMapView class responds to a number of predefined touch gestures. The default behavior of the map for each gesture type may be used as-is, supplemented, or replaced entirely. The following table is a summary of the available gestures and their default behavior.

To select a visible map object, tap the screen with one finger.
To zoom the map in a fixed amount, tap the screen twice with one finger. Tap continuously to make a continuous zoom.
To zoom out a fixed amount, tap the screen with two fingers. Tap continuously to make a continuous zoom.
To move the map, press and hold one finger to the screen, and move it in any direction.
Press and hold two fingers to the screen and move them in the same direction. This gesture does not have a predefined map action.
To pan the map with momentum, press and swipe one finger on the screen. The map continues to move in the same direction, and gradually slow to a stop.
To continuously zoom in or out, press and hold two fingers to the screen, and increase or decrease the distance between them.

Pressing and holding one finger to the screen activates the long press gesture. This gesture does not have a predefined map action.

The time required to trigger a long press gesture can be customized using the NMAMapView longPressDuration property. The default value for this property is one second.

Controlling the NMAMapView Gesture Response

Any of the gestures listed above may be selectively enabled or disabled on an NMAMapView instance using the enableMapGestures: and disableMapGestures: methods. These methods take a single input parameter that is an "or" combination of NMAMapGestureType values, which are defined in NMAMapGesture.h. The state of a specific gesture may be checked with isMapGestureEnabled:.

The following code shows how to disable all panning gestures:

// mapView is a valid NMAMapView instance
[mapView disableMapGestures:NMAMapGestureTypePan];

Gesture Delegation

To receive notifications of gestures, you can implement the NMAMapGestureDelegate and use the corresponding handler methods. For example:

@implementation MyGestureDelegate
// ...
-(void)mapView:(NMAMapView*)mapView didReceiveTapAtLocation:(CGPoint)location
  // a gesture was received
  // location is available through the "location" parameter
Note: Implementing the handler method does not have any impact on how the map responds to the gesture. For example, the logic within mapView:didReceiveDoubleTapAtLocation: is called when the map has zoomed in.