smart-mirror icon indicating copy to clipboard operation
smart-mirror copied to clipboard

Show traffic to work

Open dionzarek opened this issue 10 years ago • 19 comments

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

dionzarek avatar Feb 04 '16 17:02 dionzarek

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.

evancohen avatar Feb 04 '16 19:02 evancohen

This would be awesome

nandor690 avatar Feb 05 '16 08:02 nandor690

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 avatar Feb 05 '16 18:02 kurtdb

@kurtdb Does the traffic.js or "show traffic" command as defined in your repository works fine?

Shubham0209 avatar Feb 08 '16 18:02 Shubham0209

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.

kurtdb avatar Feb 08 '16 18:02 kurtdb

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 avatar Feb 09 '16 01:02 evancohen

@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.

Shubham0209 avatar Feb 09 '16 05:02 Shubham0209

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.

evancohen avatar Feb 09 '16 10:02 evancohen

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 avatar Feb 16 '16 14:02 kurtdb

@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.

evancohen avatar Feb 16 '16 21:02 evancohen

Would you put the home and work address information into the config file?

dardub avatar Feb 17 '16 00:02 dardub

@dardub yeah, you would. As well as mode of transportation (car, bike, bus, walk).

evancohen avatar Feb 17 '16 01:02 evancohen

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)

kurtdb avatar Feb 17 '16 12:02 kurtdb

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.

kurtdb avatar Feb 18 '16 12:02 kurtdb

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)

kurtdb avatar Feb 18 '16 16:02 kurtdb

Very cool man. Thanks for the work. I'll be trying this out later tonight. For now......yard work :-(

nandor690 avatar Feb 18 '16 21:02 nandor690

Kurt, you think you are ready to send a PR? I haven't had the chance to try it yet, but it sounds ready!

evancohen avatar Feb 18 '16 23:02 evancohen

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)

kurtdb avatar Feb 19 '16 06:02 kurtdb

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 :)

evancohen avatar Feb 19 '16 08:02 evancohen