TallyGo navigation API wrapper in Javascript. Also features component to animate iOS and Android client location updates on a map.
Install via npm:
npm install tallygo-js
yarn add tallygo-js
Or as a script tag:
<script src="https://unpkg.com/[email protected]/dist/tallygo.min.js"></script>
See the examples directory for browser usage.
const TallyGo = require('tallygo-js');
const tallygo = TallyGo.configure({apiKey: '<YOUR API KEY>'})
const requestOptions = {
startPoint: [34.76151710, -112.05714849],
endPoint: [34.76260434, -112.01666952],
time: '2018-11-13T01:31:51-0800'
course: 0,
speed: 0,
requestType: 'DepartureTime',
useCarpoolLanes: false,
useExpressLanes: false
}
tallygo.request.get(requestOptions).then(
function(json) { console.log(json) }
)
The JSON response object has the following structure:
distance
(number) - the total travel distance in milesduration
(number) - estimated travel time in minutes. Will always be a sum ofpoints.t
originalStartNode
- start node ID of the edge that start point lays onoriginalEndNode
- end node ID of the edge that end point lays onrouteSegments
([RouteSegment]) - 1 or more legs for this route.distance
(number) - the total travel distance in miles for this legduration
(number) - estimated travel time in minutes for this leg.originalStartNode
- start node ID of the edge that start point lays on, for this legoriginalEndNode
- end node ID of the edge that end point lays on, for this legpoints
([Point]) - every point in the route in sequencelat
(number) - latitudelon
(number) - longitudet
(number) - estimated travel time in seconds from the previous pointd
(number) - the distance in miles from the previous pointsay
optional ([string]) - the instructions to be spoken at or near this pointnotify
optional (string) - the out-of-app notification to be displayed at or near this pointturn
optional (Turn) - the turn at this pointdir
(TurnDirection enum) - the direction of turn (or destination, when applicable)st
(Street) - the street being turned ontoname
(string) - The name of this streetfunc
({highway, localhighway, arterial, localarterial, residential, service}) - the function of the streetconnection
optional ({origin, offramp, onramp, interchange, connector, destination})dir
optional ({north, south, east, west}) - the directionality of the streethwy
optional (HighwayId) - more information about this street if it is a highwaynumber
(number) - the number of the highwaytype
(string) - ({CA, US, I, Hwy, CR, SR}) - the type of highway
instruct
optional (string) - The text describing the turn instruction for the turn-by-turn list
node
optional (number) - OSM node id associated with the pointedge
optional (number) - OSM way id which starts with this point
The library provides a convenience class for working with Route
objects.
tallygo.request.get(requestOptions).then(
function(json) {
let route = tallygo.newRoute(json)
// do something with the Route object
}
)
yarn install
yarn test
yarn build:dev
generates javascript bundles in the /dist
directory.
yarn build:docs
generates html documentation in the /documentation
directory.
yarn start
With development server running see the examples: http://localhost:9966/examples/
Documentation is available here: http://localhost:9966/documentation/