function calcRoute() {
var start = document.getElementById("start_").value;
var end = document.getElementById("end_").value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
Gives an error message in Chrome: "Uncaught TypeError: Cannot call method 'setDirections' of undefined". Could anyone suggest fixing this? thanx
You are missing (global var)
//var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({ 'map': map });
So directionsDisplay
is undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With