How can I set the colour of a Google Maps Polyline?
var myRoutePath;
myRoutePath = new google.maps.Polyline({
path: routeCoordinates,
strokeColor: "#CC33FF",
strokeWeight: 3
});
myRoutePath.setMap(map);
// Reset colour
myRoutePath.setOptions({strokeColor: 'blue'});
The above doesn't show up as an error in Firebug, but it doesn't change the color either.
Thanks for your help.
5. Click to enable the “Visibility” option under the Stylers header. Enable the “Hue” option, then select a color for the feature type you want to color on the rainbow color selector. Wait a few seconds for the Styled Maps Wizard to apply the color changes and re-render the map page in your browser.
Hover over each to see what it signifies. If you can't find the icon you want, type it into the “filter box” – it should pop up. 10. To color-code your map, just use the same method for the icons – click on the destination and when the box pops up, just click on whatever color you want to make it.
Basically looks correct to me. However, if this is your code verbatim then you immediately overwrite the color. Hence, I guess you are getting a blue polyline from the start. Try setting a timer to see the transition:
setTimeout(function () {
myRoutePath.setOptions({strokeColor: 'blue'});
}, 3000);
Color names are still not supported as a color, use the hex version instead
myRoutePath.setOptions({strokeColor: '#0000FF'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With