I cannot find this in the docs anywhere but it should be an easy answer for anyone who knows OpenLayers on the inside. In OpenLayers 4.2, what are the possible key values for listeners: during instantiation of an ol.Map object and what are the possible event values that can be passed to e.g. ol.Map.getView().on(event, function, opt_this) to trigger it?

3 Answers 3


Perhaps these could be useful.



change (ol.events.Event) - Generic change event. Triggered when the revision counter is increased.

click (ol.MapBrowserEvent) - A click with no dragging. A double click will fire two of this.

dblclick (ol.MapBrowserEvent) - A true double click, with no dragging.

moveend (ol.MapEvent) - Triggered after the map is moved.

movestart (ol.MapEvent) - Triggered when the map starts moving.

pointerdrag (ol.MapBrowserEvent) - Triggered when a pointer is dragged.

pointermove (ol.MapBrowserEvent) - Triggered when a pointer is moved. Note that on touch devices this is triggered when the map is panned, so is not the same as mousemove.

postcompose (ol.render.Event)

postrender (ol.MapEvent) - Triggered after a map frame is rendered.

precompose (ol.render.Event)

propertychange (ol.Object.Event) - Triggered when a property is changed.

singleclick (ol.MapBrowserEvent) - A true single click with no dragging and no double click. Note that this event is delayed by 250 ms to ensure that it is not a double click.
  • This is what I was looking for. I want to mention though that change with out appending :resolution caused my map to have really poor responsiveness. Not sure why.
    – medley56
    Commented Sep 7, 2017 at 21:38

If you are programming in VS Code, you can Shift click on map or on new Map() and see the actual TypeScript code which has all those event listener functions. For example, for v5.3.0 OpenLayers it opens PluggableMap.d.ts Typescript source code and I can see these types of event listeners for map object:

  • map.on('change', listener)
  • map.on('change:layerGroup', listener)
  • map.on('change:size', listener)
  • map.on('change:target', listener)
  • map.on('change:view', listener)
  • map.on('click', listener)
  • map.on('dblclick', listener)
  • map.on('error', listener)
  • map.on('moveend', listener)
  • map.on('movestart', listener)
  • map.on('pointerdrag', listener)
  • map.on('pointermove', listener)
  • map.on('postcompose', listener)
  • map.on('postrender', listener)
  • map.on('precompose', listener)
  • map.on('propertychange', listener)
  • map.on('rendercomplete', listener)
  • map.on('singleclick', listener)

Each of these have equivalent map.once(eventType, listener) and map.un(eventType, listener) functions. once() will be called once, un() is for unregistering event listener.

OpenLayer Map Documentation v5.3.0: https://openlayers.org/en/v5.3.0/apidoc/module-ol_Map-Map.html OpenLayer latest Map Documentation: https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html

The link shared by Ian Turton for Event API is broken. Instead have a look at v5.3.0 event: https://openlayers.org/en/v5.3.0/apidoc/module-ol_events_Event-Event.html or latest BaseEvent: https://openlayers.org/en/latest/apidoc/module-ol_events_Event-BaseEvent.html

  • Can listen a event when a layer was added? Commented Jun 12 at 5:42

Event subtypes are listed on the API page while it is your responsibility to provide the listener methods as explained on the events page.

Applications do not normally create event instances. They register (and unregister) event listener functions, which, when called by the library as the result of an event being dispatched, are passed event instances as their first argument. Listeners can be registered and unregistered on all objects descending from ol.Observable. All event instances have a target property, which corresponds to the object on which the event was dispatched. By default, this within the listener also refers to the target, though this can be configured in the listener registration function. Some classes have their own event type, which return additional properties; see the specific event class page for details.

  • The links are broken.
    – Worth Lutz
    Commented Oct 5, 2018 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.