Important: To provide Realtime trip information with VehiclePosition feeds, refer to Select a trip with TripDescriptor.
You can use VehiclePosition feeds to provide Realtime trip information about the status of a transit vehicle on a particular trip.
Get vehicle status updates
A vehicle_position
message can provide information about the current status of the vehicle on a particular trip.
For vehicles that are assigned to a trip: Provide a VehiclePositions feed with a well-matched TripDescriptor, accurate position
information, and a timestamp
at which the position was measured.
You can use a VehiclePosition message when you provide:
- The vehicle’s most updated
position
with thetimestamp
of the reading - The
trip descriptor
- The
vehicle descriptor
For every subsequent stop, we use a prediction algorithm to forecast the ETA of the bus at that stop, given its current position. This information is displayed to the user in the app and also affects the search results.
If the latest vehicle position and other information isn't available, the last-known position and other data should be provided with the original position timestamp
measured. Learn more about how data gaps affect realtime feeds.
VehicleDescriptor is necessary to track a trip’s vehicle over time. It should be unique for each feed, and stable during the trip duration. To ensure that the vehicle is trackable, provide the vehicle descriptor id
.
Example code:
vehicle_position {
trip {
route_id: "route1"
direction_id: "0"
start_time: "10:10:00"
start_date: "20160203"
}
vehicle {
id: "route1-v1"
}
position {
latitude: 4066265190
longitude: 3862204692
}
timestamp: 1458508943
}
}
For fixed schedules, the actual delay is displayed:
For frequency based schedules, the arrival time for the next trip displayed without any delay information.
Use the occupancy_status
field along with the position of the vehicle_position
message. This will appear in the UI as a graphic indicator.
Example code:
vehicle {
trip {
trip_id: xxx
start_time: 12:34:56
...
occupancy_status: CRUSHED_STANDING_ROOM_ONLY
}
}
Updates that come through the VehiclePosition feed display the Realtime position of vehicles on Google Maps.