A Dazzle widget showing predictions for next arrivals at a TfL stop point, powered by Transport for London's Unified API.
- Copy
TflStopPointArrivals.js
to your dashboard project. - Add to your widgets and configure. For example:
{
widgets: {
...,
YourWidgetKey: {
type: TflStopPointArrivals,
title: 'Next bus',
props: {
stopPointId: '490011348E',
refreshInterval: 10000,
lineIds: [
'131',
'152',
],
limit: 3,
},
},
},
layout: {...}
}
Name | Type | Required | Default | Description |
---|---|---|---|---|
stopPointId | string |
Yes | N/A | Unique stop point ID, as provided by TfL's API. |
refreshInterval | number |
No | 10,000ms | Interval for refreshing the widget, in milli-seconds. |
lineIds | string[] |
No | All lines | When provided, filter out lines for which the id is not specified. |
limit | number |
No | 3 | Maximum number of arrivals to display. |
Styling is achieved using Bootstrap v4 Card component and a custom WidgetFrame
.
See dazzle-bootstrap-seed to achieve similar results. Or change the render()
method and make it your own!
Arrivals are displayed by shortest waiting time first.
The number of predictions returned by TfL may vary, as such using a limit only guaranties that the number of results displayed will be between 0 and the limit, included. Filtering by line IDs may further reduce the number of results displayed.
I only tested for bus stops, but stop points for other modes of transport should work seamlessly.
More informations are returned by TfL's API and could be displayed, for example the destinationName
. See Swagger for the full contract: https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/StopPoint/StopPoint_Arrivals