<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var myLatLng = new google.maps.LatLng(28.553767,-81.380653);
var myOptions = {
zoom:15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: myLatLng,
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
});
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}
function c() {
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
distance = "The distance between the two points on the chosen route is: "+response.routes[0].legs[0].distance.text;
distance += "<br/>The aproximative driving time is: "+response.routes[0].legs[0].duration.text;
document.getElementById("distance_road").innerHTML = distance;
}
});
}
</script>
</head>
<body onLoad="initialize()">
<div>
<form>
<table width="100%" border="0">
<tr>
<td><h4>Find the direction between two locations</h4></td>
</tr>
</table>
<h5>Starting Address:
<input type="text" id="start" size="50" />
Ending Address: <input type="text" id="end" size="50" />
<input type="button" value="Submit" name="calcRoute" onClick="c()"/>
</h5>
<table width="100%" border="0">
<tr>
<td> </td>
</tr>
</table>
</form>
</div>
<table width="100%" border="0">
<tr>
<td> </td>
</tr>
</table>
<center><div style="width:100%; height:10%" id="distance_road"></div></center>
<div id="map_canvas" style="float:left;width:70%; height:54%"></div>
<div id="directionsPanel" style="float:right;width:30%;height:10%"></div>
</body>
</html> |