Monday, June 14, 2010

Re: Json not returning distance value

I am not going against terms of use, I will use with the key as
mentioned below, let me if it is also against terms of use

StringBuilder sbUrl = new StringBuilder();
sbUrl.Append("http://maps.google.com/maps/nav?
key=ABQIAAAAn9...&output=js&oe=utf8&q=
");
sbUrl.AppendFormat("from:{0}",
HttpUtility.UrlEncode(AddressA));
sbUrl.AppendFormat("+to:{0}",
HttpUtility.UrlEncode(AddressB));

Uri googleUrl = new Uri(sbUrl.ToString());

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(googleUrl);
HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
using (StreamReader reader = new
StreamReader(response.GetResponseStream()))
{
try
{

String gResponse = reader.ReadToEnd();

GoogleDirections directions =
JsonConvert.DeserializeObject(gResponse,
typeof(GoogleDirections)) as GoogleDirections;


double myMiles =
Convert.ToDouble(directions.Directions.Distance.meters) * 0.000621371;
Response.Write("Json Distance : " + myMiles.ToString()
+ "<br>");
}
catch
{
Response.Write("Error");
}


}

Let me know if I am against terms of use, if not please advise me to
correct the code.


On Jun 14, 2:23 pm, Rossko <ros...@culzean.clara.co.uk> wrote:
> > I am only interested in distance value.
>
> That sounds like you plan to use it outside of the terms of use.
>    http://code.google.com/apis/maps/documentation/directions/#Directions...
> "the Directions API may only be used in conjunction with displaying
> results on a Google map; using Directions data without displaying a
> map for which directions data was requested is prohibited...."

--
You received this message because you are subscribed to the Google Groups "Google Maps API" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate