Creates a polygon around a linestring. Provides an option to vary the thickness. Usage:
var path = [ [0, 0], [25, 25], [13, 13] ];
var width = 5; //or an array for each line segment [ 5, 10, 15 ]
var poly = line2Polygon(path, width);
Credit: https://gist.github.com/kekscom/4194148