Google Maps – commute traffic as your wallpaper/lock screen wallpaper

How about live traffic updates as your lock screen wallpaper?

There is a tutorial made by Joao Dias showing you how to set NASA daily pictures as wallpaper. I thought, I would up the ante a little. When I started to work on this project, I thought it will be a quick one. Turned out, the solution was more difficult than initially anticipated. A 5 min tutorial turned into a several hours long mad googling session! I REALLY hope you will like the Google Maps traffic wallpaper.

Without further introductions, here is Google Maps traffic wallpaper. This wallpaper is set for a period of time before commute to and from work. Could you just ask Google for this information? Yes, you can do that, however, I find this to be less intrusive, you don’t have to think about it and the information is ready when you need it most. It’s a great addition to your Google Now updates.

Map – the issue

mapThe information is best obtained by taking a screenshot. This is not that simple if your phone has a screen lock on it. I can force the Tasker to take the screenshot – whether with a Run Shell, AutoTools etc. But most of the time I would end up with a black screen, or lock screen picture.

I had to scrap this idea and come up with something else. While googling for solutions I came across screenshot services like screenshotmachine.com. The free account allows you for a 100 API calls per month. The API is pretty much self-explanatory. I got stuck for a long time with the fact that my link was able to pull a correct image via the web browser but not through the HTTP GET action. I managed to bypass the link issue by using the Google URL shortener. It worked.

Profile

screenshot_20161013-063042The context is simple (feel free to change it). I’m using a time condition to change the current wallpaper for 30 min before my commute to work, and before my return home. Outside of these times, the wallpaper will revert to one of your choices. You can use the Tasker to set the wallpaper, and if you on Android 7 you can use AutoTools to set the screen lock wallpaper separately.

Task

Formatting the link

As per API guide, the link looks like this:

http://api.screenshotmachine.com/?key=YOUR_API_KEY&size=F&cacheLimit=0&format=PNG&url=URL_SHORTENED_BY_GOOGLE

Open up the google maps and get the directions for your commute (both ways) and cut the link short before the encoded part. (The link has been updated with the &cacheLimit=0 to prevent the request from getting the cached image – credit: Zach Paiz) Here is my example and here is where it ends (remove stuff associated with/data=!3m1…. these are the time of travel and we want to have this generated each time):

https://www.google.co.uk/maps/dir/Field+View+B+%26+B+Yarm,+Green+Lane,+Yarm+TS15+9EH,+United+Kingdom/Manchester+Piccadilly+Station,+Manchester+M60+7RA,+United+Kingdom /(dont need the rest)....../data=!3m1!4b1!4m13!4m12!1m5!1
TASKER Profile:Going Home
Profile: Coming Back Home 
	Time: From 18:30 Till 19:00
Enter: Get Map Return 
		Abort Existing Task
	A1: Variable Set [ Name:%UrlCommute To:SHORT_URL_HERE
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: HTTP Get [ Server:Port:http://api.screenshotmachine.com/
            ?key=YOUR_KEY_HERE&size=X&format=PNG&cacheLimit=0&url=%UrlCommute
            Path: Attributes: Cookies: User Agent: Timeout:15 
            Mime Type:image/png Output File:/sdcard/Tasker/new.png 
            Trust Any Certificate:On ] 
	A3: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
	A4: Load Image [ Source:/sdcard/Tasker/new.png 
            Max Width Or Height:0 Respect EXIF Orientation:Off ] 
	A5: Crop Image [ From Left (%):45 From Right (%):0 
            From Top (%):0 From Bottom (%):0 ] 
	A6: Save Image [ File:/sdcard/Tasker/new1.png 
            Image Quality:85 Delete From Memory After:On ] 
	A7: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Tasker/new1.png
            Timeout (Seconds):60 ] 

Exit: Reset 
	A1: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Download/IMG_20160923_104847.jpg 
            Timeout (Seconds):60 ]
TASKER Profile:Going to Work
Profile: Going To Work 
	Time: From 06:45 Till 08:15
Enter: Get Map 
	Abort Existing Task
	A1: Variable Set [ Name:%UrlCommute To:SHORT_URL_HERE 
            Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: HTTP Get [ Server:Port:http://api.screenshotmachine.com/
            ?key=YOUR_KEY_HERE&size=X&format=PNG&cacheLimit=0&url=%UrlCommute 
            Path: Attributes: Cookies: User Agent: Timeout:15 
            Mime Type:image/png Output File:/sdcard/Tasker/new.png 
            Trust Any Certificate:On ] 
	A3: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ] 
	A4: Load Image [ Source:/sdcard/Tasker/new.png 
            Max Width Or Height:0 Respect EXIF Orientation:Off ] 
	A5: Crop Image [ From Left (%):45 From Right (%):0 
            From Top (%):0 From Bottom (%):0 ] 
	A6: Save Image [ File:/sdcard/Tasker/new1.png 
            Image Quality:85 Delete From Memory After:On ] 
	A7: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper: 
            /storage/emulated/0/Tasker/new1.png Timeout (Seconds):60 ] 

Exit: Reset 
	A1: AutoTools Wallpapers/Muzei 
            [ Configuration:Lock Screen Wallpaper:
            /storage/emulated/0/Download/IMG_20160923_104847.jpg
            Timeout (Seconds):60 ]

Use that google code with the URL shortener if it doesn’t work directly for you to compile the final screenshot API request. I’m going to use HTTP GET to receive the picture of the current traffic and route options. As both routes will use exactly the same routines but different links it makes sense to set the shortened links as variable %UrlCommute. In the action set the link + the variable in the Server:Port. Set the Mime Type to Image/png and select a file location. This is where the picture will be stored. Before the image can be used – we will need to crop it. this-one

Cropping

If you selected the image to be full size (X) you will end up with a consistent image of 1024 x 768px. This is far from perfect and the crop is in place. You can use both information if you wish. The list view and the map view but I will show you the cropping to get the map. You will need 3 actions. Load, Crop and Save image. Crop from the left 45%.

Wallpaper

Using Muzei and AutoTools you can set the new wallpaper to both home screen and lock screen. If you are using Tasker actions only you will be limited to a home wallpaper only. Select the correct files and you are ready to rock.

Finishing the project Google Maps traffic wallpaper

After reading all this, I’d assume you will have no problem with setting up a profile for the reversed journey. You don’t even have to change the file names.  only reverse the link and set up a  new time.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE