Hi,
I am New to google maps Api i want to get the route Map From One Place To the Other .So i Have used the regular coding but cant get with it.I am getting the place and everything except the Line From start point to End Point .
And My coding is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Advanced Directions</title>
<script src=" http://maps.google.com/?file=api&v=2.x&key=MyKey"
type="text/javascript"></script>
<style type="text/css">
v\:*
{
behavior:url(#default#VML);
}
</style>
<style type="text/css">
body {
font-family: Verdana, Arial, sans serif;
font-size: 11px;
margin: 2px;
}
table.directions th {
background-color:#FFC0C0;
}
img {
color: #000000;
}
</style>
<script type="text/javascript">
var map;
var gdir;
function initialize()
{
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
// === Array for decoding the failure codes ===
var reasons=[];
reasons[G_GEO_SUCCESS] = "Success";
reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value.";
reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address.";
reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons.";
reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed.";
reasons[G_GEO_BAD_REQUEST] = "A directions request could not be successfully parsed.";
reasons[G_GEO_MISSING_QUERY] = "No query was specified in the input.";
reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";
// === catch Directions errors ===
GEvent.addListener(gdir, "load",function()
{
alert('hi');
var poly=gdir.getPolyline();
map.addOverlay(poly);
} );
GEvent.addListener(gdir, "error", function()
{
var code = gdir.getStatus().code;
var reason="Code "+code;
if (reasons[code])
{
reason = reasons[code]
}
alert("Failed to obtain directions, "+reason);
});
setDirections("San Francisco", "Mountain View");
}
function setDirections(fromAddress, toAddress)
{
alert(fromAddress);
alert(toAddress);
// alert(locale);
gdir.load("from: "+fromAddress+" to: "+toAddress);
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<h2>Maps API Directions Illustrated</h2>
<form action="#" onsubmit="setDirections(this.from.value, this.to.value); return false">
<table>
<tr><th align="right">From: </th>
<td><input type="text" size="25" id="fromAddress" name="from" /></td>
<th align="right"> To: </th>
<td align="right"><input type="text" size="25" id="toAddress" name="to" /></td></tr>
<tr><th> </th>
<td colspan="3">
<input name="submit" type="submit" value="Get Directions!" /> </td></tr>
</table>
</form>
<br/>
<table class="directions">
<tr><th>Formatted Directions</th><th>Map</th></tr>
<tr>
<td valign="top"><div id="directions" style="width: 275px"></div></td>
<td valign="top"><div id="map_canvas" style="width: 310px; height: 400px"></div></td>
</tr>
</table>
</body>
</html>
can Any one Solve this .
Or can Any one get me the coding to get the shortest way to reach from one Place To many Palces in Google maps API.Need The shortest distance
a-->b
a-->c
a-->d