使用谷歌路线服务,我得到两个地点之间的交通结果,并在地图上显示结果。我想更改两个位置之间的线条颜色的颜色。我正在使用 google.maps.Polyline 更改主线颜色,但是有些部分的线是虚线的(以显示您必须步行的位置),但这并没有更改为与主线相同的颜色。我该怎么做才能改变虚线的颜色?
/* change line color */
var polylineOptionsActual = new google.maps.Polyline({
strokeColor: '#9f98ff',
strokeWeight: 5
});
function initialize() {
/* create map */
var mapOptions = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
/* directions */
var rendererOptions = {
map: map,
suppressMarkers: true,
polylineOptions: polylineOptionsActual
}
directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
directionsDisplay.setPanel(document.getElementById('directions-results'));
}
function getDirections() {
/* directions request */
var request = {
origin: document.getElementById('from-input').value,
destination: document.getElementById('to-input').value,
travelMode: google.maps.TravelMode.TRANSIT
};
/* display directions */
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}