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
492 stars 115 forks source link

Decorators drawn outside of line boundaries when zoomed out #86

Open crowmagnumb opened 6 years ago

crowmagnumb commented 6 years ago

I have a line decorator defined as ...

    arrows = L.polylineDecorator(latlngs, {
        color: "#107d9f",
        patterns: [
            {
                offset: 40,
                repeat: 80,
                symbol: L.Symbol.arrowHead({
                    pixelSize: 15,
                    pathOptions: { fillOpacity: 1, weight: 0 }
                })
            }
        ]
    });

... which results in this which is fine except for a few stray arrows drawn ...

screen shot 2018-07-02 at 10 47 05 am

... but further zoomed out looks like this ...

screen shot 2018-07-02 at 10 46 25 am

In both cases it should not draw any arrows if they don't fit within the bounds of the line. Not sure how to make this happen. By choosing an offset of zero it helped. Arrowheads still drawn but at least they were clustered near the points. But that doesn't look good zoomed in.

crowmagnumb commented 6 years ago

I have submitted a pull request that fixes this for me.

jb2b38 commented 5 years ago

Having the exact same problem, this pull request fixes the bug.