angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.31k stars 6.73k forks source link

help(map-directions-renderer): Can't display multiple routes #26693

Open brendan343 opened 1 year ago

brendan343 commented 1 year ago

Is this a regression?

The previous version in which this bug was not present was

No response

Description

hi real beginner here with this but i'm trying to display all the routes on the maps using the below as per the documentation within the html: <map-directions-renderer *ngIf="(dResultTransit | async) as directionsResults1" [directions]="directionsResults1"></map-directions-renderer>

i have the request to provide route alternatives: let request: google.maps.DirectionsRequest = { origin: this.origin, destination: this.destination, travelMode: google.maps.TravelMode.TRANSIT, provideRouteAlternatives: true, transitOptions: { modes: transitMode, routingPreference: this.transitPreference }, }

this is followed with providing the dResultTransit as defined: dResultTransit: Observable<google.maps.DirectionsResult | undefined> | undefined;

this.dResultTransit = this.DirectionsServiceTransit.route(this.TransitRequest()).pipe(map(response => response.result));

Reproduction

Steps to reproduce:

  1. I tried different travel modes and turning off the provide route alternatives to ensure the displaying of the routes is correct
  2. I tried using different machines and os and i am getting the same result

Expected Behavior

I expect 4 routes to be displayed as per below image

Actual Behavior

however, this is only currently displaying 1 route. image

Environment

felipeemsabino commented 1 year ago

Same here. Any update?

brendan343 commented 1 year ago

Update:

Unfortunately I am still unable to display multiple routes at once. My workaround at the moment is to have to map-renderer lines (1 for transit and the other for driving).

I had my sidebar to toggle the provided alternative routes for transit so at least the polylines are refreshed for each route. Didnt really solve the problem but at least its displaying the different polyline for each route.

Screenshot 2023-07-02 at 5 26 48 PM Screenshot 2023-07-02 at 5 27 03 PM Screenshot 2023-07-02 at 5 27 38 PM

Hope others have better luck than me!