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/tallygo-js@1.0.3/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 miles -
duration
(number) - estimated travel time in minutes. Will always be a sum ofpoints.t
-
originalStartNode
- start node ID of the edge that start point lays on -
originalEndNode
- end node ID of the edge that end point lays on -
routeSegments
([RouteSegment]) - 1 or more legs for this route.-
distance
(number) - the total travel distance in miles for this leg -
duration
(number) - estimated travel time in minutes for this leg. -
originalStartNode
- start node ID of the edge that start point lays on, for this leg -
originalEndNode
- end node ID of the edge that end point lays on, for this leg -
points
([Point]) - every point in the route in sequence-
lat
(number) - latitude -
lon
(number) - longitude -
t
(number) - estimated travel time in seconds from the previous point -
d
(number) - the distance in miles from the previous point -
say
optional ([string]) - the instructions to be spoken at or near this point -
notify
optional (string) - the out-of-app notification to be displayed at or near this point -
turn
optional (Turn) - the turn at this point-
dir
(TurnDirection enum) - the direction of turn (or destination, when applicable) -
st
(Street) - the street being turned onto-
name
(string) - The name of this street -
func
({highway, localhighway, arterial, localarterial, residential, service}) - the function of the street -
connection
optional ({origin, offramp, onramp, interchange, connector, destination}) -
dir
optional ({north, south, east, west}) - the directionality of the street -
hwy
optional (HighwayId) - more information about this street if it is a highway-
number
(number) - the number of the highway -
type
(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 point -
edge
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/