PowerShell : Get Directions using Google Map API
HOW IT WORKS :
Today we’ll use the very popular Google Map’s Directions API to generate instructions to navigate between two cities using PowerShell.
Just to show you how it work, please go to the below mentioned URL by passing the required parameters.
You’ll reach to an XML page with all the necessary data. Now just we need some Data Mining from this page using Powershell and we have the information we need.
WHAT IS GOOGLE MAP DIRECTION 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 Directions API is a service that calculates directions between locations using an HTTP request.
You can search for directions for several modes of transportation, include transit, driving, walking or cycling. Directions may specify origins, destinations and waypoints either as text strings (e.g. “Chicago, IL” or “Darwin, NT, Australia”) or as latitude/longitude coordinates. The Directions API can return multi-part directions using a series of waypoints.
GET THE SCRIPT : Click here to go to my GitHub gist to get the code.
HOW TO USE IT :
Just provide Origin, Destination and you will get the directions. The script will choose the Transportation mode as ‘Driving‘ By default, 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
Also, You’ll find Three Modes of transport(‘Driving’,’Bicycling’,’Walking’) available in the function for which you can opt to get the directions
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.
In my next post, I will show you, how to play with this information and make your computer give you Voice enabled Instructions using the Speech API (SAPI). So stay tuned fellas !
Thank you for Stopping by 🙂