HERE Android SDK Developer's Guide

MapGesture

The interface MapGesture is a member of com.here.android.mpa.mapping .

Interface Summary

public abstract interface MapGesture

Encapsulates all user interactions and touch gestures.

[For complete information, see the section Interface Details]

Nested Class Summary

Table 1. Nested Classes in MapGesture
Nested Classes

public static abstract interface MapGesture.OnGestureListener

Event Listener interface for gesture events.

Method Summary

Table 2. Methods in MapGesture
Methods

public abstract void addOnGestureListener (OnGestureListener listener)

Deprecated: As of SDK 3.3, use addOnGestureListener(MapGesture.OnGestureListener, int, boolean) instead.

Adds a MapGesture.OnGestureListener to listen for map gesture events.

public abstract void addOnGestureListener (OnGestureListener listener, int priority, boolean isSync)

Adds a MapGesture.OnGestureListener to listen for map gesture events.

public abstract void cancelKineticPanning ()

Cancels all currently active motions caused by kinetic panning.

public abstract boolean isAutoSnapToNorthEnabled ()

Returns a boolean value indicating whether map automatically rotates to the north if previous rotation did not exceed certain small amount of degrees starting from north.

public abstract boolean isDoubleTapEnabled ()

Returns a boolean value indicating whether double-tap is enabled for the MapGesture .

public abstract boolean isFixedMapCenterOnMapRotateZoom ()

Returns a boolean value indicating whether the transform center is applied on rotate and zoom interactions.

public abstract boolean isKineticFlickEnabled ()

Returns a boolean value indicating whether flick-to-scroll (with kinetic momentum) is enabled for the MapGesture .

public abstract boolean isLongPressEnabled ()

Returns a boolean value indicating whether long-press is enabled for this MapGesture .

public abstract boolean isPanningEnabled ()

Returns a boolean value indicating whether panning is enabled for this MapGesture .

public abstract boolean isPinchEnabled ()

Returns a boolean value indicating whether pinch is enabled for this MapGesture .

public abstract boolean isRotateEnabled ()

Returns a boolean value indicating whether two-finger rotation is enabled for this MapGesture .

public abstract boolean isSingleTapEnabled ()

Returns a boolean value indicating whether single-tap is enabled for this MapGesture .

public abstract boolean isTiltEnabled ()

Returns a boolean value indicating whether tilt is enabled for this MapGesture .

public abstract boolean isTwoFingerPanningEnabled ()

Returns a boolean value indicating whether two-finger panning interactions are enabled for this MapGesture .

public abstract boolean isTwoFingerTapEnabled ()

Returns a boolean value indicating whether two-finger tap is enabled for this MapGesture .

public abstract void removeOnGestureListener (OnGestureListener listener)

Removes an existing MapGesture.OnGestureListener.

public abstract MapGesture setAllGesturesEnabled (boolean enabled)

Sets all possible kinds of gesture interaction to be either enabled or disabled for the MapGesture .

public abstract MapGesture setAutoSnapToNorthEnabled (boolean enabled)

Sets whether map automatically rotates to the north if previous rotation did not exceed certain small amount of degrees starting from north.

public abstract MapGesture setDoubleTapEnabled (boolean enabled)

Sets whether double-tap interactions are enabled or disabled for this MapGesture .

public abstract MapGesture setFixedMapCenterOnMapRotateZoom (boolean lock)

Sets whether the transform center is applied during multitouch gestures.

public abstract MapGesture setKineticFlickEnabled (boolean enabled)

Sets whether flick-to-scroll (with kinetic momentum) interactions are enabled for this MapGesture .

public abstract MapGesture setLongPressEnabled (boolean enabled)

Sets whether long-press interactions are enabled or disabled for this MapGesture .

public abstract MapGesture setPanningEnabled (boolean enabled)

Sets panning interactions to be either enabled or disabled for this MapGesture .

public abstract MapGesture setPinchEnabled (boolean enabled)

Sets whether pinch interactions are enabled or disabled for this MapGesture .

public abstract MapGesture setRotateEnabled (boolean enabled)

Sets whether two-finger rotate interactions are enabled for this MapGesture .

public abstract MapGesture setSingleTapEnabled (boolean enabled)

Sets whether single-tap interactions are enabled or disabled for this MapGesture .

public abstract MapGesture setTiltEnabled (boolean enabled)

Sets whether tilt interactions are enabled or disabled for this MapGesture .

public abstract MapGesture setTwoFingerPanningEnabled (boolean enable)

Sets whether the two-finger panning interaction is enabled for this MapGesture .

public abstract MapGesture setTwoFingerTapEnabled (boolean enabled)

Sets whether two-finger tap gestures are enabled or disabled for this MapGesture .

Interface Details

Encapsulates all user interactions and touch gestures.

Default gestures made available through this interface include:

  • Panning - allows a user to pan around a map by holding one finger on the screen and dragging to a new geographical location
  • Kinetic Flick - allows a user to pan around a map by "flicking" the screen with one finger (faster than panning but less precise)
  • Pinch To Zoom - allows a user to zoom out or zoom in by, respectively, pinching or spreading two fingers being held to the screen
  • Double Tap - allows a user to zoom in to view closer geographical details
  • Two-Finger Tap - allows a user to zoom out to view a wider geographical area
  • Two-Finger Vertical Drag - allows a user to tilt a map to an angle between "straight down from above" and "looking toward the horizon"
  • Two-Finger Rotate - allows a user to rotate a map to a desired compass orientation
  • Single Tap - does not encapsulate any default behavior. Developers can add application-specific functionality to this gesture.
  • Long Press - does not encapsulate any default behavior. Developers can add application-specific functionality to this gesture.

Various setter methods of this interface allow an application developer to set specific gestures as either enabled or disabled. There is also a setAllGesturesEnabled(boolean) method which simultaneously enables or disables all gestures.

Note: the default functionality of one or more gestures can be customized by implementing the MapGesture.OnGestureListener class and overriding appropriate methods to define desired gesture functionality (this must be done to make use of the long press gesture).

Method Details

public abstract void addOnGestureListener (OnGestureListener listener)

Deprecated: As of SDK 3.3, use addOnGestureListener(MapGesture.OnGestureListener, int, boolean) instead.

Adds a MapGesture.OnGestureListener to listen for map gesture events. When there are multiple listeners subscribed to the MapGesture events, the order when a subscriber receives a callback is determined by the order when they are added to MapGesture .

It is important that after adding an MapGesture.OnGestureListener in an user application, remember to call removeOnGestureListener(MapGesture.OnGestureListener) when there's no longer a need to listen for map gesture events to free up application resources.

Parameters:

See also:

addOnGestureListener(OnGestureListener, int, boolean)

removeOnGestureListener(OnGestureListener)

public abstract void addOnGestureListener (OnGestureListener listener, int priority, boolean isSync)

Adds a MapGesture.OnGestureListener to listen for map gesture events. When there are multiple listeners subscribed to the MapGesture events, all synchronous subscriber(s) will receive the gesture event callback first, followed by the asynchronous subscriber(s), unless the event is consumed by one of the synchronous subscribe(s). Within the same group of synchronous or asynchronous subscriber(s), the order when a subscriber receives a callback is then determined first by the priority, then within the same priority, it is determined next by the order when they are added to MapGesture . Once one of the subscriber(s) consumes a gesture event, no other subscriber(s) will receive the event.

OnGestureListeners added by way of addOnGestureListener(MapGesture.OnGestureListener, int, boolean) can return their callbacks synchronously or asynchronously depending on the value of isSync used when calling the method.

If a listener has previously been added as an asynchronous listener and is added again as a synchronous listener, it will automatically be de-registered from the asynchronous to ensure the same listener can only be an asynchronous or synchronous but not both. Similarly, the same applies for the case of synchronous listener then switching to asynchronous.

It is important that after adding an MapGesture.OnGestureListener in an user application, remember to call removeOnGestureListener(MapGesture.OnGestureListener) when there's no longer a need to listen for map gesture events to free up application resources.

Parameters:

  • listener

    A MapGesture.OnGestureListener to add to this MapGesture

  • priority

    An int representing the priority of this listener to be added. The value Integer.MIN_VALUE is reserved for internal use.

  • isSync

    Use true to add this listener to receive callbacks synchronously, use false otherwise. Only synchronous listeners can consume a gesture event.

See also:

removeOnGestureListener(OnGestureListener)

public abstract void cancelKineticPanning ()

Cancels all currently active motions caused by kinetic panning.

public abstract boolean isAutoSnapToNorthEnabled ()

Returns a boolean value indicating whether map automatically rotates to the north if previous rotation did not exceed certain small amount of degrees starting from north. By default, this value is set to true.

Returns:

True if auto snap to north is enabled, false otherwise.

public abstract boolean isDoubleTapEnabled ()

Returns a boolean value indicating whether double-tap is enabled for the MapGesture . By default, this value is set to true.

Returns:

True if double-tap is enabled, false otherwise

public abstract boolean isFixedMapCenterOnMapRotateZoom ()

Returns a boolean value indicating whether the transform center is applied on rotate and zoom interactions. The default value is false.

Returns:

True if transform center is fixed during zoom, False otherwise.

public abstract boolean isKineticFlickEnabled ()

Returns a boolean value indicating whether flick-to-scroll (with kinetic momentum) is enabled for the MapGesture . By default, this value is set to true.

Returns:

True if kinetic flick is enabled, false otherwise

public abstract boolean isLongPressEnabled ()

Returns a boolean value indicating whether long-press is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if long-press is enabled, false otherwise

public abstract boolean isPanningEnabled ()

Returns a boolean value indicating whether panning is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if panning is enabled, false otherwise

public abstract boolean isPinchEnabled ()

Returns a boolean value indicating whether pinch is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if pinch is enabled, false otherwise

public abstract boolean isRotateEnabled ()

Returns a boolean value indicating whether two-finger rotation is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if rotate is enabled, false otherwise

public abstract boolean isSingleTapEnabled ()

Returns a boolean value indicating whether single-tap is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if single-tap is enabled, false otherwise

public abstract boolean isTiltEnabled ()

Returns a boolean value indicating whether tilt is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if tilt is enabled, false otherwise

public abstract boolean isTwoFingerPanningEnabled ()

Returns a boolean value indicating whether two-finger panning interactions are enabled for this MapGesture . By default, this value is set to true.

Returns:

A boolean true if enabled, false if disabled.

public abstract boolean isTwoFingerTapEnabled ()

Returns a boolean value indicating whether two-finger tap is enabled for this MapGesture . By default, this value is set to true.

Returns:

True if two-finger tap is enabled, false otherwise

public abstract void removeOnGestureListener (OnGestureListener listener)

Removes an existing MapGesture.OnGestureListener. Call this method to free up application resources when there's no longer any need to listen for map gesture events.

Parameters:

public abstract MapGesture setAllGesturesEnabled (boolean enabled)

Sets all possible kinds of gesture interaction to be either enabled or disabled for the MapGesture .

Parameters:

  • enabled

    A boolean specifying whether all gestures are enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setAutoSnapToNorthEnabled (boolean enabled)

Sets whether map automatically rotates to the north if previous rotation did not exceed certain small amount of degrees starting from north. By default, this value is set to true.

Parameters:

  • enabled

    A boolean specifying whether auto snap to north is enabled.

Returns:

The modified MapGesture itself.

public abstract MapGesture setDoubleTapEnabled (boolean enabled)

Sets whether double-tap interactions are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether double-tap is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setFixedMapCenterOnMapRotateZoom (boolean lock)

Sets whether the transform center is applied during multitouch gestures. If this value is enabled, rotation and zoom will always be applied using the transform center, instead of a point relative the touch interaction.

Parameters:

  • lock

    A boolean specifying whether transform center is fixed . Default is false

Returns:

The modified MapGesture itself.

public abstract MapGesture setKineticFlickEnabled (boolean enabled)

Sets whether flick-to-scroll (with kinetic momentum) interactions are enabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether kinetic flick is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setLongPressEnabled (boolean enabled)

Sets whether long-press interactions are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether long-press is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setPanningEnabled (boolean enabled)

Sets panning interactions to be either enabled or disabled for this MapGesture . Note that when panning is disabled, kinetic panning will also be blocked, even if it is enabled.

Parameters:

  • enabled

    A boolean specifying whether panning is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setPinchEnabled (boolean enabled)

Sets whether pinch interactions are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether pinch is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setRotateEnabled (boolean enabled)

Sets whether two-finger rotate interactions are enabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether rotate is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setSingleTapEnabled (boolean enabled)

Sets whether single-tap interactions are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether single-tap is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setTiltEnabled (boolean enabled)

Sets whether tilt interactions are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether tilt is enabled

Returns:

The modified MapGesture itself.

public abstract MapGesture setTwoFingerPanningEnabled (boolean enable)

Sets whether the two-finger panning interaction is enabled for this MapGesture .

Parameters:

  • enable

    True if two finger panning will be enabled (default). False if two-finger panning will not be enabled.

Returns:

The modified MapGesture itself.

public abstract MapGesture setTwoFingerTapEnabled (boolean enabled)

Sets whether two-finger tap gestures are enabled or disabled for this MapGesture .

Parameters:

  • enabled

    A boolean specifying whether two-finger tap is enabled

Returns:

The modified MapGesture itself.