Using the Google Maps API, we can input a starting address and a destination address and it will spit out the best route to take as well as the estimated travel time. And yes, it accounts for current traffic and road conditions!
Credits to redditor Golden-Death for figuring this out!
Prerequisites
Instructions
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.
Credits to redditor Golden-Death for figuring this out!
Prerequisites
- 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).
Instructions
- 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,
Code:1600 Pennsylvania Ave NW, Washington, DC 20500
Code: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 Serverort to
Code:https://maps.googleapis.com:443
Code:/maps/api/directions/json?origin=%start&destination=%destination&travelmode=driving&departure_time=now&key=%api
- Variables --> Variable Set. Name %GMAPS to %HTTPD. This will set the output from the Google Maps API to a variable we will parse using a Javascriptlet.
- Code --> Javascriptlet. Here is the code you need:
Code:var routeSplit = JSON.parse(global('GMAPS')); var routetraffic = routeSplit.routes[0].legs[0].duration_in_traffic.text; var routename = routeSplit.routes[0].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.