How to calculate distance between two points using the google api with C # [closed]

0

I hope you can guide me, I am building a site where I want to consume the Google Maps API with C #, I want to know if it is possible to calculate the distance between two points by means of some function offered by the API or I have to calculate it using some function mathematical.

    
asked by Torres Erick 05.09.2018 в 20:53
source

1 answer

0

You could use the service

Distance Matrix API

then from c # basically using HttpClient invoke that api to get the calculation

Here is explained great

Google Distance Matrix API with HttpClient and Json.NET

the idea is to use something like being

using (var client = new HttpClient())
{
    var uri = new Uri(GetRequestUrl());

    HttpResponseMessage response = await client.GetAsync(uri);
    if (!response.IsSuccessStatusCode)
    {
        throw new Exception("GoogleDistanceMatrixApi failed with status code: " + response.StatusCode);
    }
    else
    {
        var content = await response.Content.ReadAsStringAsync();
        return JsonConvert.DeserializeObject<Response>(content);
    }
}

see how the answer json deserializa

    
answered by 06.09.2018 / 19:12
source