I need help with my code.
First, is my approach correct that I use the GoogleDistanceMatrix to get the real route distance and not just the linear distance?
I want to use an Geocoordinate for the origin and destination Adress but it doesnt seem to work:
public double CalculateGoogleDistance(GeoCoordinate from, GeoCoordinate to) {
DistanceMatrixRequest request = new DistanceMatrixRequest();
request.Key = "****";
request.Origins = new Location[] {
new Location(from)
};
request.Destinations = new Location[] {
new Location(to)
};
var response = GoogleApi.GoogleMaps.DistanceMatrix.Query(request);
return response.Rows.First().Elements.First().Distance.Value;
}