HOW IT WORKS :
Idea is to use the Google Map’s Distance Matrix API to calculate distance between two cities. Just to show you how it work, please navigate the below mentioned URL and pass necessary parameters. You’ll reach to an XML page which has all the necessary information.
Capture the content of this page using Powershell and the Fun begins 🙂
WHAT IS GOOGLE MAP DISTANCE MATRIX API ?
API – Application Programming Interface is a set of functions and procedures that allow the creation of applications which access the features or data of an operating system, application, or other service.
The Google Maps Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing
distance values for each pair.
GET THE SCRIPT : Click here to go to my GitHub gist to get the code.
HOW TO USE IT :
By default you have to just provide Origin, Destination and Mode (‘Driving’,’Bicycling’,’Walking’) of Transportation and you will get the distance in Unit Kilo Meters, like in the screenshot below.
If you want to change the unit into miles use the switch -InMiles and distance would be converted into Miles
If in the case Google map doesn’t find any results (ZERO_RESULTS) for the values you passed in the Parameters, the Function will prompt you the same.
Hope you guys find it useful. Thank you for Stopping by 🙂