Change route brand Google Maps V3 route

Using the google.maps.DirectionsService.route () and google.maps.DirectionsRenderer.setDirections () methods, is it possible to change the text in the information window for the destination without creating my own parser for the trip?

I could not see anything in the API, which allowed you to access route markers.

I don't want any code, just yes / no and hints for the right direction.

Current function:

   var request = {
        origin: origPoint, 
        destination: new google.maps.LatLng (dest.lat (), dest.lng ()),
        travelMode: google.maps.DirectionsTravelMode.DRIVING,
        region: "GB"
    };
    directionsService.route (request, function (result, status) {
        if (status == google.maps.DirectionsStatus.OK) {
          directionsDisplay.setDirections (result);
        }
    });

Thanks Psy

+3
source share
1 answer

I'm afraid the api does not offer direct access to info windows or access to markers.

But there are several ways to achieve these parsing parts of the result data:

  • I think the easiest way to change the text in the info window is to rewrite the start and / or end addresses of the DirectionsLegs DirectionsResult. You must do this before calling directionsDisplay.setDirections(result).
  • (. suppressMarkers suppressInfoWindows ) - - DirectionsLegs of DirectionsResult.

, , . , , .

0

Source: https://habr.com/ru/post/1735961/


All Articles