Angel Hernandez
Angel Hernandez

Reputation: 35

google maps api directions

I am working with the google maps api. I have one issue that I was wondering if other people had and if it is fixable. When using the direction feature, sometimes the routes are unnecessarily long or complex. Like the picture in this link.

Is there anything i could change in my directions code??

var directionsDisplay = new google.maps.DirectionsRenderer({
        suppressMarkers: true
    });

    var directionsService = new google.maps.DirectionsService;    

directionsService.route({
            origin: marker.position,
            destination: dest_end,
            travelMode: google.maps.TravelMode.WALKING
        }, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
            } else {
                window.alert('Directions request failed due to ' + status);
            }
        });

Upvotes: 0

Views: 537

Answers (1)

Jignesh Aakoliya
Jignesh Aakoliya

Reputation: 43

I haven't enough credit to make comment so i am answering here according to google map they have three walking route to your destination and it shows best from that routs by default, in your case this rout has 0.4 mile walking distance and other two has 0.4 and 0.5 respectively so it take smallest distance with less time.

Upvotes: 1

Related Questions