i have polyline drawn using list of points in leaflet. here code
road= new l.polyline(pointlist, { color: color, weight: 10, linecap:"square", linejoin:"bevel", opacity: 0.6, smoothfactor: 1 }); i need change color of polyline green on mouseover. using following code. it's not working.
road.on('mouseover', function (e) { var layer=e.target; layer.options["color"]="green"; console.log(layer.options["color"]); }); can give me idea how can it?
you should use setstyle method, this:
road.on('mouseover', function() { this.setstyle({ color: 'red' //or whatever style wish use; }); }); also, revert initial style on mouseout, save style in variable, , write:
road.on('mouseout', function() { this.setstyle(initialstyle) });
Comments
Post a Comment