OpenLayers Click Handler Example

# Click Handler Example

This example shows the use of the click handler.

The click handler can be used to gain more flexibility over handling click events. The handler can be constructed with options to handle only single click events, to handle single and double-click events, to ignore clicks that include a drag, and to stop propagation of single and/or double-click events. A single click is a click that is not followed by another click for more than 300ms. This delay is configured with the delay property.

The options to stop single and double clicks have to do with stopping event propagation on the map events listener queue (not stopping events from cascading to other elements). The ability to stop an event from propagating has to do with the order in which listeners are registered. With stopSingle or stopDouble true, a click handler will stop propagation to all listeners that were registered (or all handlers that were activated) before the click handler was activated. So, for example, activating a click handler with stopDouble true after the navigation control is active will stop double-clicks from zooming in.

Controls with click handlers (toggle on/off to clear output)
single only |  |
double only |  |
both |  |
single with drag |  |
single with stop |  |
double with stop |  |