1

I encountered a problem with changing the color in react-Google Maps routes, I attach the code below

{
DirectionsService.route({
              origin: new google.maps.LatLng(newProsps[0].lat, newProsps[0].lng),
              destination: new google.maps.LatLng(40.95604847, -73.84254456),
              travelMode: google.maps.TravelMode.DRIVING,
              provideRouteAlternatives: true,
            }, (result, status) => {
              if (status === google.maps.DirectionsStatus.OK) {
                  if(state.bol){
                  state.directions = result
                  }
                  else{
                    return null
                  }
              } else {
                console.error(`error fetching directions ${result}`);
              }
}

I don't understand how to change the color of the route during initialization

dippas
  • 58,591
  • 15
  • 114
  • 126
Ilya
  • 11
  • 2
  • There was an old answer you may be interested in https://stackoverflow.com/questions/35597394/how-to-change-color-of-route-in-google-map-api-after-route-is-build – Ryu Nov 14 '20 at 22:42

1 Answers1

0

Maybe you can use this code from how to change color of route in google map api after route is build inside a route

directionsDisplay = new google.maps.DirectionsRenderer({
    polylineOptions: {
      strokeColor: "red"
    }
  });
directionsDisplay.setOptions({
  polylineOptions: {
    strokeColor: 'red'
  }
});
Ryu
  • 386
  • 1
  • 6