Is it possible to create a trigger for multiple events in this manner?
map.on('click, dragstart, zoomstart', eventHandler);
If not what will be the next best way to trigger the same event handler for multiple events?
map.on('click', eventHandler);
map.on('dragstart', eventHandler);
map.on('zoomstart', eventHandler);
Is it possible to create a trigger for multiple events in this manner?
map.on('click, dragstart, zoomstart', eventHandler);
If not what will be the next best way to trigger the same event handler for multiple events?
map.on('click', eventHandler);
map.on('dragstart', eventHandler);
map.on('zoomstart', eventHandler);
Share
Improve this question
asked Feb 3, 2013 at 22:18
NyxynyxNyxynyx
63.7k163 gold badges506 silver badges856 bronze badges
0
1 Answer
Reset to default 17It is possible, just remove the ma's:
map.on('click dragstart zoomstart', eventHandler);
function eventHandler(e) {
console.log(e.type); //shows event type, i.e. "click", "dragstart" etc.
}