Search code examples
c#.netgoogle-mapsconsole-application

Nuget Package for interacting with Google Maps


I have a C# console app that I want to use to interact with the Google Maps APIs. However, I'm not sure which Nuget package to use. I have a list of city names and I want to get the distance between each city. In other words, pretend I have the following list:

Portland, OR
Las Vegas, NV
San Diego, CA

Ultimately, I want to be able to generate a matrix that looks like this.

+----------------+--------------+---------------+---------------+
|                | Portland, OR | Las Vegas, NV | San Diego, CA |
+----------------+--------------+---------------+---------------+
| Portland, OR   | 0 mi.        | 978 mi.       | 1,083 mi.     |
+----------------+--------------+---------------+---------------+
| Las Vegas, NV  | 978 mi.      | 0 mi.         | 331 mi.       |
+----------------+--------------|---------------+---------------+
| San Diego, CA  | 1,083 mi.    | 331 mi.       | 0 mi.         |
+----------------+--------------+---------------+---------------+

For that reason, I just need to figure out which Nuget package will let me query the Google Maps API and get the distance between two points. However, even after searching the packages, I can't tell which one to use. Can anyone tell me which one is the best option?


Solution

  • Probably gmaps-api-net - https://www.nuget.org/packages/gmaps-api-net/

    The project website: https://github.com/ericnewton76/gmaps-api-net

    The actual api you have to use is Direction Matrix, and it is documented here: https://developers.google.com/maps/documentation/distancematrix/