Sergey
Sergey

Reputation: 8091

How to calculate fastest or shortest way when we use DirectionsService route

I have the code like this:

var directions = new google.maps.DirectionsService();
    var request = {
        origin: start,
        destination: destination,
        waypoints: waypoints,
        provideRouteAlternatives: false,
        unitSystem: @(Model.SessionService.GetDivision().DistanceUnits.MeasurementSystem.ID == 1 ? "google.maps.UnitSystem.METRIC" : "google.maps.UnitSystem.IMPERIAL"),
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };

    directions.route(request, function(response, status) {

....

And it works great but is it possible to calculate the route with different options? Like shortest route or quickest route? Does Google allow it?

Upvotes: 0

Views: 658

Answers (1)

ScottE
ScottE

Reputation: 21630

By default you will get the optimal route.

All you can do is supply provideRouteAlternatives = true to the request object, and then inspect the results for the shortest distance / whatever else matches your criteria.

Upvotes: 1

Related Questions