How to track vehicle traffic in real time on the OSMmap using the loca

I’m trying to create an application that tracking the movement of vehicles, so I first plotted stop icons on the map, and now I want the vehicle movement to be displayed on the map. I found a location_package with which I can do this. Also, since I use OSM maps , it is flutter_map package(I saw a solution for google maps, but I need to use free maps), then I need to display the traffic on it and I don’t understand where to give the code that I wrote below.

Also I wanted not just animate this markers but take the real live movement.

Maybe I need to use a different package to solve my issues?

Also I take all longitude and latitude from my own API and the code ise down bellow.

Now i am using this code below to display the all icons of moving transport but it dosen’t work and I am confused.

Can you guys give me a hint what I am missingin this project?

the code

class TransportMove extends StatefulWidget {
_TransportMoveState createState() => _TransportMoveState();

class _TransportMoveState extends State {
List listDir;
Future <List> futureMove;
List allMarkers = [];


void initState() {
futureMove = fetchLoc();

Widget build(BuildContext context) {
return FutureBuilder<List>(
future: futureMove,
builder: (context, snapshot){
}else if(snapshot.hasError){
listDir =;
listDir.forEach((element) {
allMarkers = => Marker(
point: latLng.LatLng(e.uLong, e.uLat),
width: 10,
height: 10,
builder: (ctx) => Icon(Icons.directions_car, color:,)
)).toList(growable: true);
return Text(“${snapshot.error}”);
}return CircularProgressIndicator();

class LocationTraking {
LocVeh _currentLocation;

StreamController _locationController = StreamController();

Stream get locationStream =>;

LocationService() {
// Request permission to use location
location.requestPermission().then((granted) {
if (granted != null) {
// If granted listen to the onLocationChanged stream and emit over our controller
location.onLocationChanged.listen((locationData) {
if (locationData != null) {
uLat: locationData.latitude,
uLong: locationData.longitude,

var location = Location();

Future getLocation() async {
try {
var userLocation = await location.getLocation();
_currentLocation = LocVeh(
uLat: userLocation.latitude,
uLong: userLocation.longitude,
} on Exception catch (e) {
print(‘not work’);
return _currentLocation;
the API with long and lat which I give to transport on flutter map

class LocVeh {

int srvId;
int ttId;
String uModel;
DateTime uTimenav;
double uLat;
double uLong;
int uSpeed;
int uCourse;

factory LocVeh.fromJson(Map<String, dynamic> json) => LocVeh(
srvId: json[“srv_id”],

ttId: json["tt_id"],
uTimenav: DateTime.parse(json["u_timenav"]),
uLat: json["u_lat"].toDouble(),
uLong: json["u_long"].toDouble(),
uSpeed: json["u_speed"],
uCourse: json["u_course"],


Map<String, dynamic> toJson() => {
“srv_id”: srvId,
“tt_id”: ttId,
“u_model”: uModel,
“u_timenav”: uTimenav.toIso8601String(),
“u_lat”: uLat,
“u_long”: uLong,
“u_speed”: uSpeed,
“u_course”: uCourse,

please if you solved the problem tell me, i faced the same problem

Please remove the link to since it does not contain anything related to the question.