我在我的离子项目中使用Google Map,并使用DirectionsService和 DirectionsRenderer 我正在使用以下代码显示多条路线
this.directionsService.route({
origin: this.origin,
destination: this.end1,
travelMode: 'WALKING',
provideRouteAlternatives: true
}, (response, status) => {
if (status === 'OK') {
console.log(response);
for (var i = 0; i < response.routes.length; i++) {
this.renderDirections(response, this.map, i)
}
} else {
window.alert('Directions request failed due to ' + status);
}
});
,rederDirection功能为:
renderDirections(result, map, index) {
var directionsRenderer1 = new google.maps.DirectionsRenderer({
directions: result,
routeIndex: index,
map: map,
panel: document.getElementById('directionsPanel'),
polylineOptions: {
strokeColor: "green",
strokeWeight:7
}
});
console.log("routeindex1 = ", directionsRenderer1.getRouteIndex());
}
我很想点击其他路线并将颜色更改为点击路线的活动颜色,我该如何实现呢?