Hunzla Ali
Hunzla Ali

Reputation: 423

Custom color of draw polygon on leaflet map

I am drawing polygon on leaflet map

 this.polygonDrawer = new L.Draw.Polygon(this.map);

How can i customize color of this polygon? Like i want red color polygon should draw so where i can give this color option?

Upvotes: 0

Views: 3183

Answers (1)

Falke Design
Falke Design

Reputation: 11338

There is a setOptions function.

this.polygonDrawer = new L.Draw.Polygon(this.map, {shapeOptions: {color: '#f00'}});

//or

this.polygonDrawer.setOptions({shapeOptions: {color: '#f00'}});

http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#l-draw-polyline-setoptions

PS: leaflet geoman is a very nice and up-to-date leaflet draw alternativ library

Upvotes: 3

Related Questions