I am trying to provide walking directions on campus between buildings. When I use the following code, the start and end coordinates get placed on the nearest named road rather than the specific path that was specified.
var request = {
origin: "34.23974770397957,-118.53099968624116",
destination: "34.240064785369974,-118.52827992630006",
travelMode: google.maps.DirectionsTravelMode.WALKING
};
directionsService = new google.maps.DirectionsService();
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
You can see the problem here http://www.csun.edu/~kjm39451/maps/mapsError/main.html by selecting the drop down for anything in both fields.
But I want the result to look like this https://maps.google.com/maps?saddr=34.23974770397957,-118.53099968624116&daddr=34.240064785369974,-118.52827992630006&hl=en&ll=34.239825,-118.530614&spn=0.003721,0.004823&sll=34.23962,-118.52964&sspn=0.003721,0.004823&geocode=FQR1CgIdSFzv-A%3BFUF2CgId6Gbv-A&dirflg=w&mra=ls&t=m&z=18
How can I use google maps api to give directions just like google maps does?