Credits to redditor Golden-Death for figuring this out!
- A Google Maps API account. I will quote the instructions you need to set up the account and the API from the thread above:
First, get a google maps API account here: https://developers.google.com/maps/ Click "Get Started" and then click on Google Maps Android API. Then click on "Get a Key". Create a new project and name it whatever you want. Generate an API key, and take note of it. From here on out, I will refer to this key as YOUR_API_KEY.
Click on the "Overview" button on the left tab (of the API manager screen), then expand the Google Maps APIs section. Click on "Google Maps Directions API", and then enable it at the top. From here, you can also visit the USAGE tab to see how many requests you have made for directions, or visit the QUOTAS tab to limit your daily quota to the free amount so you never get billed (or, at least that's my understanding).
- Variables --> Variable Clear. Name %GMAPS.
- Variables --> Variable Set. Name %start, and set it to your starting address. Replace any spaces with a + sign. For example,
1600 Pennsylvania Ave NW, Washington, DC 20500
- Variables --> Variable Set. Name %destination, and set it to your destination address. Use the same convention as above.
- Variables --> Variable Set. Name %api, and set it to your Google Maps API key.
- Net --> HTTP Get. Set Server:Port to
var routeSplit = JSON.parse(global('GMAPS')); var routetraffic = routeSplit.routes.legs.duration_in_traffic.text; var routename = routeSplit.routes.summary;
- Alert --> Say. Text: Hello, you should take %routename to get to your destination the fastest. Expected travel time is %routetraffic.
How do you use this task, you ask? You can use it as an exit task when disconnecting from your home wifi. You can use it to trigger when connecting to your car's bluetooth. You can use a location trigger when leaving your home. You can use an NFC tag. The choice is yours.
Here's a screenshot of the task:
I've attached an XML of the task below. You can import it by moving it to /sdcard/Tasker/tasks, then opening Tasker and long-pressing on the tasks tab up top then pressing import.