event.Mapper

Extends IEventTrigger.

Event mapper. Allows managing propagation of events along the hierarchy of event managers.

Constructor | Methods

Constructor

Parameters:

Parameter Default value Description
targetEventManager *

Type: IEventManager

The event manger that the mapper propagates initiated events to.

mappingTable *

Type: Object

Table of mapping rules. A hash where the keys are types of events and the values are the corresponding mapping functions, or Boolean values. A mapping function for a specific type of event receives an event instance that was initiated on the mapper, and must return the event instance for propagating further along the hierarchy, or null if propagation must be prohibited. The boolean values are interpreted as follows:
  • true - Events of this type are propagated through the hierarchy unchanged.
  • false - Events of this type are not propagated through the hierarchy.
The "*" key is also available in the table for the default processing rule.

* Mandatory parameter/option.

Example:

// Creating and setting up the event mapper that will transform the "click" event in the root
// geo object collection into a "geoobjectclick" event on the map itself.
var mapper = new ymaps.event.Mapper(myMap.events, {
    "*": false,
    "click": function (event) {
        return new ymaps.Event({
             type: "geoobjectclick",
             target: map,
             originalTarget: event.get("target")
        }, event);
    }
});

myMap.geoObjects.events.setParent(mapper);

Methods

Name Returns Description
fire(type[, eventObject])

IEventTrigger

Triggers an event.

Inherited from IEventTrigger.