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);
It is possible, just remove the comma's:
map.on('click dragstart zoomstart', eventHandler);
function eventHandler(e) {
console.log(e.type); //shows event type, i.e. "click", "dragstart" etc.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With