Given this function, I want to replace the color with a random color generator.
document.overlay = GPolyline.fromEncoded({
color: "#0000FF",
weight: 10,
points: encoded_points,
zoomFactor: 32,
levels: encoded_levels,
numLevels: 4
});
How can I do it?
There is no need for a hash of hexadecimal letters. JavaScript can do this by itself:
You can also use HSL available on every good browser (http://caniuse.com/#feat=css3-colors)
This will give you only bright colors, you can play around with the brightness, saturation and alpha.
I doubt anything will be faster or shorter than this one:
Challenge!
I like this one:
'#' + (Math.random().toString(16) + "000000").substring(2,8)
Random color generation with brightness control:
ES6 version.
Random color
Random alpha, random color.