leaflet-event-forwarder
Version:
Catches unhandled canvas layer events and re-dispatches them to the next layer in the stack
45 lines (36 loc) • 1.24 kB
Markdown
A plugin for leaflet `v1^`.
Catches unhandled canvas layer events and re-dispatches them to the next pane in a container.
```javascript
const map = L.map("map");
// prepare a container to hold our z stackable layer panes
const container = map.createPane('stack-container');
const myEventForwarder = new L.eventForwarder({
// ref to leaflet map
map: map,
// events to forward
events: {
click: true,
mousemove: true
},
// throttle options for mousemove events (same as underscore.js)
throttleMs: 100,
throttleOptions: {
leading: true,
trailing: false
}
});
// enable event forwarding
myEventForwarder.enable();
// disable event forwarding
myEventForwarder.disable();
```
- Based largely on [this gist](https://gist.github.com/perliedman/84ce01954a1a43252d1b917ec925b3dd)
by [perliedman](https://gist.github.com/perliedman)
Apache 2
[]: https://badge.fury.io/js/leaflet-event-forwarder.svg
[]: https://www.npmjs.com/package/leaflet-event-forwarder
[]: https://img.shields.io/npm/dt/leaflet-event-forwarder.svg