Show traffic to work
Maybe it will be great to see current traffic before go to work or somewhere, like "Show traffic to work" :)
https://developers.google.com/maps/documentation/javascript/examples/layer-traffic
I've been meaning to implement this for a while. I'm thinking that the mirror should be "smart" about this and always show time to work between 6:00am and 10:00am on Monday - Friday.
This would be awesome
I think this might be the better API from google: https://developers.google.com/maps/documentation/directions/intro#traffic-model.
Bing has a somewhat similar API as this will give you the traffic incidents, but it's not for a route, rather for a region: https://msdn.microsoft.com/en-us/library/hh441726.aspx.
@kurtdb Does the traffic.js or "show traffic" command as defined in your repository works fine?
It's a really old version, made specifically for my situation (being Belgium). It's not a portable solution.
In the future I think someone (maybe me) will implement the API calls for the google or microsoft service. That might be a better fit.
Best API for this is probably Bing Maps. It accepts two locations and returns a property called travelDurationTraffic which is a total time for travel including traffic.
Documentation: https://msdn.microsoft.com/en-us/library/gg636957.aspx
@evancohen can you please send me link of any particular page or website(or list down the steps here) from where i can learn how to incorporate api's into your project. I dont have any knowledge about web development and how to handle api's.
Well, you're going to need to understand at least some basic programming to do any of that stuff. There are lots of classes that you can take online, Codecademy is one of them.
You'll want to take the classes on:
- HTML & CSS
- JavaScript
- APIs
- Git
- AngularJS
There are a few others I would recommend, but that's probably plenty to get you started.
Isn't the bing API going to be a bit heavy weight? If you look at the response, it returns the complete directions from one place to another. 99% of all the returned data will just be garbage and we will ignore it.
@kurtdb Yup, totally wasted information - I agree. On the other hand this API is free and provides the necessary information. Having to fetch a couple of extra KB of data isn't really that big of a deal.
Would you put the home and work address information into the config file?
@dardub yeah, you would. As well as mode of transportation (car, bike, bus, walk).
The basic version of the traffic-service is currently ready at https://github.com/kurtdb/smart-mirror/tree/traffic.
However it does not display anything yet. It just sets the $scope.trafficInformation to the current time in the following form: 45mins (15mins extra).
To be able to define the mode of transportation, I will have to take another look at the Bing Maps API. (might be able to do that tonight or tomorrow)
Ok, the current version in the branch is displaying the traffic information under the weather on the screen.
What I'm looking at next (before I create a pull request) is support public transportation and walking.
Public transit and walking is integrated. The way it is displayed and the way the public transit api works is under consideration, but driving and walking should work. (although walking gives an extra, which is impossible)
Very cool man. Thanks for the work. I'll be trying this out later tonight. For now......yard work :-(
Kurt, you think you are ready to send a PR? I haven't had the chance to try it yet, but it sounds ready!
Not quite ready yet: going to finish the walking part today, make sure the service doesn't return the message (should be built on the front-end) and show a message if no public transit is available between the locations. (right now bing returns a 404, which makes very much sense)
I merged in the work that you did and changed a few things in #99. Let me know what you think of it, I'd like to merge it in and close this issue out :)