bbecquet / Leaflet.PolylineDecorator

A plug-in for the JS map library Leaflet, allowing to define patterns (like dashes, arrows, icons, etc.) on Polylines.
MIT License
496 stars 114 forks source link

No action when bind onclick or bindPopup #73

Closed GarryBrown closed 6 years ago

GarryBrown commented 6 years ago

I saw issue about FeatureGroup. It must work, but it's doesn't. Maybe i had a mistake.

From dosc FeatureGroup

L.featureGroup([marker1, marker2, polyline])
    .bindPopup('Hello world!')
    .on('click', function() { alert('Clicked on a member of the group!'); })
    .addTo(map);

From your example with listener and bindPopup

var arrow = L.polyline([[57, -19], [60, -12]], {}).addTo(map);
var arrowHead = L.polylineDecorator(arrow, {
      patterns: [
          { offset: '100%', repeat: 0, symbol: L.Symbol.arrowHead(
                   { pixelSize: 15, polygon: false, pathOptions: { stroke: true } }
             ) }
            ]
        })
            .bindPopup('Hello world!')
            .on('mouseover', function () { console.log('test') })
            .addTo(map);
bbecquet commented 6 years ago

Hi, and sorry for waiting so long. You're right, it's using LayerGroup instances internally which don't respond to event binding. Using FeatureGroup everywhere solves the problem. I'll publish a fix soon.

bbecquet commented 6 years ago

It should be fixed in version 1.6.0. Thanks for your help! Don't hesitate to re-open if there are still bugs.