Bus Tracking
Parents can track their child's school bus in real-time — view assigned bus, live location on a map, route stops, and driver details.
Assigned Bus
GET /parent/bus-tracking/bus-assignment?studentId={id}
{
"data": {
"busId": "uuid",
"busNumber": "KA-01-AB-1234",
"driverName": "Ramesh Kumar",
"driverPhone": "+919876543210",
"capacity": 40,
"routeName": "Route A - Whitefield",
"pickupStop": "Silk Board Junction",
"dropStop": "School Gate"
}
}
Active Trip
GET /parent/bus-tracking/active-trip?studentId={id}
{
"data": {
"tripId": "uuid",
"tripType": "PICKUP",
"status": "STARTED",
"currentStopIndex": 3,
"etaMinutes": 15,
"startedAt": "2024-04-01T07:30:00Z"
}
}
Live Bus Location
GET /parent/bus-tracking/get-bus-location?busId={busId}
{
"data": {
"lat": 12.9356,
"lng": 77.6245,
"speed": 35,
"heading": 90,
"lastUpdated": "2024-04-01T07:45:00Z"
}
}
Route Stops
GET /parent/bus-tracking/get-route-stops?busId={busId}
{
"data": {
"stops": [
{ "id": "uuid", "name": "Silk Board Junction", "sequence": 1, "eta": "07:30" },
{ "id": "uuid", "name": "BTM Layout", "sequence": 2, "eta": "07:40" },
{ "id": "uuid", "name": "School Gate", "sequence": 3, "eta": "07:55" }
]
}
}
Student Boarding Status
GET /parent/bus-tracking/student-status?studentId={id}&tripId={tripId}
{
"data": {
"studentId": "uuid",
"tripId": "uuid",
"status": "boaded",
"markedAt": "2024-04-01T07:32:00Z",
"stopName": "Silk Board Junction"
}
}
| Status | Meaning |
|---|---|
boaded | Student boarded the bus |
alighted | Student got off the bus |
absent | Student was absent |
no_show | Student did not show up at stop |
UI — Live Map
The home screen shows a live bus location on OpenStreetMap via flutter_map:
// BusTrackingScreen
class BusTrackingScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final busVM = context.watch<BusTrackingViewModel>();
return FlutterMap(
options: MapOptions(initialCenter: LatLng(
busVM.currentLocation.lat,
busVM.currentLocation.lng,
)),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
),
MarkerLayer(
markers: [
// Bus marker
Marker(
point: LatLng(busVM.currentLocation.lat, busVM.currentLocation.lng),
width: 40,
height: 40,
child: const Icon(Icons.directions_bus, color: Colors.blue, size: 40),
),
// Home marker
Marker(
point: LatLng(busVM.homeLocation.lat, busVM.homeLocation.lng),
width: 40,
height: 40,
child: const Icon(Icons.home, color: Colors.green, size: 40),
),
],
),
],
);
}
}
Driver Info
GET /parent/bus-tracking/driver-info?busId={busId}
Returns driver name and phone number for the assigned bus.