Leaflet event: how to propagate to overlapping layers

前端 未结 2 747
醉酒成梦
醉酒成梦 2020-12-06 06:43

Let\'s say I have some overlapping layers and each layer has a click event. When I click on the map, I\'d like to know which layers are clicked on, though the click event st

2条回答
  •  感情败类
    2020-12-06 07:24

    There is a leaflet plugin for propagating events to the underlying layers: https://github.com/danwild/leaflet-event-forwarder

    You can use it in your javascript to enable event-forwarding, e.g.:

    const myEventForwarder = new L.eventForwarder({
      map: map,
      events: {click: true, mousemove: false}
    });
    

提交回复
热议问题