function calculateRoute() {
var startLocation = document.getElementById('start').value;
var endLocation = document.getElementById('end').value;
var requestParams = {
origin: startLocation,
destination: endLocation,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(requestParams, function(directionsResponse, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(directionsResponse);
var routeDetails = directionsResponse.routes[0];
var summaryContainer = document.getElementById('directions_panel');
summaryContainer.innerHTML = '';
// Display summary information for each route.
for (var i = 0; i < routeDetails.legs.length; i++) {
var routeSegmentNumber = i + 1;
summaryContainer.innerHTML += '<b>Route Segment: ' + routeSegmentNumber + '</b><br>';
summaryContainer.innerHTML += routeDetails.legs[i].start_address + ' to ';
summaryContainer.innerHTML += routeDetails.legs[i].end_address + '<br>';
summaryContainer.innerHTML += routeDetails.legs[i].distance.text + '<br><br>';
}
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
The event listener for my button is not firing. I want to display directions using two dropdown list controls with server-side controls but the button event is not being triggered. What should I do?
<asp:Button ID="submitBtn" runat="server" OnClientClick="return calculateRoute();" Text="Submit" />
Can someone please explain how to call a JavaScript method from the server-side? Thank you.