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?
Here are my two versions for a random hex code generator.
If you're a noob like me, clueless about hexadecimals and such, this might be more intuitive.
You just need to end up with a string such as
'rgb(255, 123, 220)'
Almost all of the previous short hand methods are generating invalid hex codes (five digits). I came across a similar technique only without that issue here:
Test
Try this in the console:
You can use colorchain.js to generate a sequence of colors with varying hues.
Here is another take on this problem.
My goal was to create vibrant and distinct colors. To ensure the colors are distinct I avoid using a random generator and select "evenly spaced" colors from the rainbow.
This is perfect for creating pop-out markers in Google Maps that have optimal "uniqueness" (that is, no two markers will have similar colors).
If you wish to see what this looks like in action see http://blog.adamcole.ca/2011/11/simple-javascript-rainbow-color.html.
Yet another random color generator: