开发者

Set colour of a Polyline in Google Maps v3?

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'});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜