Hello,
is there a way to get the distance, seperated by the different types of
road.
In my example I would like to know the distance between 2 points traveled
on the highway.
In the Json returned from the distance matrix api I only get the total
distance and duration:
ServicePointManager.ServerCertificateValidationCallback +=
(RemoteCertificateValidationCallback)((sender, certificate, chain,
sslPolicyErrors) => true);
var ApiKey = "ApiKey - Here";
string baseURL =
"https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins={0},{1}&destinations={2},{3}&key={4}";
string url2 = string.Format(baseURL,olat,olng,dlat,dlng,ApiKey);
HttpWebRequest GETRequest =
(HttpWebRequest)WebRequest.Create(url2);
GETRequest.Method = "GET";
GETRequest.Accept = "application/json";
WebProxy theProxy = new WebProxy();
theProxy.BypassProxyOnLocal = true;
theProxy.Credentials = CredentialCache.DefaultCredentials;
GETRequest.Proxy = theProxy;
try
{
HttpWebResponse GETResponse =
(HttpWebResponse)GETRequest.GetResponse();
DataContractJsonSerializer serializer = new
DataContractJsonSerializer(typeof(RootClass));
//
using (var sr = new
StreamReader(GETResponse.GetResponseStream()))
{
var root =
(RootClass)serializer.ReadObject(sr.BaseStream);
return root.rows[0].elements[0].distance.ToString();
}
}
catch
{
return ("error");
}
Thank you in advance for any comments on this matter,
Kenny
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-maps-js-api-v3.
For more options, visit https://groups.google.com/d/optout.