我正在使用 react-google-maps 在网站中呈现地图。在为 DirectionsService 使用航点时,我对每条线的 strokeColor 有疑问。如何在它们之间更改 strokeColor 以及使用 DirectionsService 后如何回调。这是我的来源相同的例子:
https://tomchentw.github.io/react-google-maps/#directionsrenderer
let DirectionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
DirectionsService.route(
{
origin: new google.maps.LatLng(10.8441402, 106.76757429999999),
destination: new google.maps.LatLng(10.8463797,106.7721405),
travelMode: google.maps.TravelMode.DRIVING,
optimizeWaypoints: true,
waypoints: [
{
location: new google.maps.LatLng(10.8454946,106.764759),
stopover : false
}
]
},
(result, status) => {
console.log(result);
if (status === google.maps.DirectionsStatus.OK) {
this.setState({directions: result})
return (typeof callback == 'function') && callback( result);
} else {
console.error(`error fetching directions`, result);
}
}
);
感谢帮助