How can I set the colour of a Google Maps Polyline?
var myRoutePath;
myRoutePath = new google.maps.Polyline({
pat开发者_Go百科h: 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.
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'});
精彩评论