Skip to content

Instantly share code, notes, and snippets.

@veltman
Created July 8, 2013 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veltman/5952642 to your computer and use it in GitHub Desktop.
Save veltman/5952642 to your computer and use it in GitHub Desktop.
Changing the stroke-linecap of a polyline in leaflet
testPolyline = new L.Polyline(
[[34.03900467904445,-118.55810165405272],
[34.13766755862196,-118.50643157958984],
[34.15187463170986,-118.36292266845702],
[34.168635904722734,-118.3292770385742],
[34.16196020316907,-118.25923919677734]]);
testPolyline.addTo(map);
//Left-click makes it flat
testPolyline.on('click',function() {
this._path.style["stroke-linecap"] = "butt";
});
//Right-click makes it round
testPolyline.on('contextmenu',function() {
this._path.style["stroke-linecap"] = "round";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment