Class: IWTouchUtils

IWTouchUtils

A helper class to easily add touch gesture behaviour to a map for mobile devices.

Currently supported devices are all iOS devices (iPad, iPhone, and iPod Touch) and Android devices (smartphones and tablets) with Android 2+. Multi touch gestures (map zooming) start with Android 3.

The default behaviour adds the following gestures to the map:

  • Touching the map without movement (tap gesture): Identifies POIs, search hits etc. and firess an ontap event on the map
  • Touching the map with two fingers (two finger tap gesture): Zooms out one level and fires an ontap event on the map
  • Touching the map twice (double tap gesture): Zooms in one level and fires an ondoubletap event on the map
  • Touching the map for a longer time (hold gesture): No default behaviour, but fires an onhold event on the map
  • Touching and dragging the map with one finger (drag gesture): Moves the map
  • Touching and dragging the map with two or more fingers (transform gesture): Zooms the map


new IWTouchUtils()

Methods


addTouchGestures(map)

Adds default touch behaviour to the map. This depends on the default behaviour set by IWTouchUtils.setTouchOptions().
Parameters:
Name Type Description
map IWMap a map
Returns:
Type
void

isTouchScreenAvailable()

Checks whether touch gestures supported by the map are available on the device or not.
Returns:
Type
boolean

setTouchOptions(map, options)

Sets some options regarding touch gestures. Supported options:
Property Description Value Default
reloadOnMove reload tiles during map movements (slower) boolean false
preventDefault Prevent default browser behavior for touch gestures (i.e. scrolling or zooming the page) boolean true
defaultBehaviour.tap toggles default behaviour for tap events boolean true
defaultBehaviour.twoFingerTap toggles default behaviour for two finger tap events boolean true
defaultBehaviour.doubleTap toggles default behaviour for double tap events boolean true
defaultBehaviour.drag toggles default behaviour for drag events boolean true
defaultBehaviour.transform toggles default behaviour for transform events boolean true

Example:

var options =
{
	reloadOnMove: false,
	defaultBehaviour:
	{
		tap: false,
		twoFingerTap: false,
		doubleTap: false,
		drag: true,
		transform: true
	}
};

IWTouchUtils.setTouchOptions(options);
IWTouchUtils.addTouchGestures(map);

IWEventManager.addCustomListener(map, 'ontap', function(event)
{
	// implement own tap event handler here
});

Parameters:
Name Type Description
map IWMap a map
options object a set of options as defined above
Returns:
Type
void