I am able to get the route directions between two places on the map. There are multiple routes (PFA of the result I am getting). I want the KML file to be retrieved from those resulting routes. Can anyone help me retrieving the KML format of the routes.
I used the following code for displaying the routes.
function calcRoute()
{
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var directionsRequest = {
origin:start,
destination:end,
provideRouteAlternatives: true,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
};
directionsService.route(directionsRequest,
function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
if(directionsDisplay != null) {
directionsDisplay.setMap(null);
directionsDisplay = null;
map = null;
}
directionsDisplay = new google.maps.DirectionsRenderer();
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay.setMap(map);
for (var i = 0, len = response.routes.length; i < len; i++) {
new google.maps.DirectionsRenderer({
map: map,
directions: response,
routeIndex: i,
draggable: true
});
}
alert(ctaLayer.getUrl());
} else {
$("#error").append("Unable to retrieve your route<br />");
}
}
);
}