Coder Social home page Coder Social logo

js-leavelater's Introduction

When to Leave

A simple application that allows you to enter an origin and a destination. It will continually poll the Google Directions API service while there is traffic. Once traffic has died down, it will notify you.

Next Steps

  1. Convert to a script that handles this process and reports when complete.
  2. Convert to a web app that uses a web worker
  3. Include a way to send an SMS when traffic is over
  4. Add additional flags and options like pessimistic and optimistic notification when traffic has fallen off by X%.

Dev Notes

Gotchas

For the API to return traffic info, you have to specify a traffic model (best_guess is the default, and pessimistic is exactly that) but you also have to specify a departure time in seconds since the epoch. A special value of now can also be used.

Env

API Token from Google: AIzaSyC8tAh9LPl_KfWtuDWNgpiFbwrLnV0Rn6U

You must use https when using a token.

API Usage

Documentation is at: https://developers.google.com/maps/documentation/directions/intro

This is a valid GET request to the API using my personal API token.

https://maps.googleapis.com/maps/api/directions/json?origin=305+Walnut+St+Redwood+City+CA&destination=201+3rd+St+94607&key=AIzaSyC8tAh9LPl_KfWtuDWNgpiFbwrLnV0Rn6U&mode=driving&traffic_model=best_guess&departure_time=now

Here's a properly formatted curl request with the default traffic_model because its unspecified

curl -i 'https://maps.googleapis.com/maps/api/directions/json?origin=305+Walnut+St+Redwood+City+CA&destination=201+3rd+St+94607&key=AIzaSyC8tAh9LPl_KfWtuDWNgpiFbwrLnV0Rn6U&mode=driving&departure_time=now'

Here's a properly formatted curl request

curl -i 'https://maps.googleapis.com/maps/api/directions/json?origin=305+Walnut+St+Redwood+City+CA&destination=201+3rd+St+94607&key=AIzaSyC8tAh9LPl_KfWtuDWNgpiFbwrLnV0Rn6U&mode=driving&traffic_model=pessimistic&departure_time=now'

One more curl request, formatted using the --data and --get switches

curl -i --get https://maps.googleapis.com/maps/api/directions/json --data 'origin=305+Walnut+St+Redwood+City+CA&destination=201+3rd+St+94607&departure_time=now&key=AIzaSyC8tAh9LPl_KfWtuDWNgpiFbwrLnV0Rn6U'

js-leavelater's People

Stargazers

Ilias Tsangaris avatar

Watchers

James Cloos avatar Brett Levenson avatar  avatar

Forkers

ilias-t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.