Ric*_*ard 7 google-maps google-maps-api-3
如何设置Google地图折线的颜色?
var myRoutePath;
myRoutePath = new google.maps.Polyline({
path: routeCoordinates,
strokeColor: "#CC33FF",
strokeWeight: 3
});
myRoutePath.setMap(map);
// Reset colour
myRoutePath.setOptions({strokeColor: 'blue'});
Run Code Online (Sandbox Code Playgroud)
以上内容并未在Firebug中显示为错误,但它也不会改变颜色.
谢谢你的帮助.
对我来说基本上看起来是正确的。但是,如果这是您的逐字代码,那么您会立即覆盖颜色。因此,我猜你从一开始就得到了一条蓝色的折线。尝试设置一个计时器来查看转换:
setTimeout(function () {
myRoutePath.setOptions({strokeColor: 'blue'});
}, 3000);
Run Code Online (Sandbox Code Playgroud)