0

I'm building a Flutter app that uses the google_maps_flutter plugin to display a map with a car that moves based on the user's location. I have an API that provides the car's latitude and longitude every minute, which I use to update the car's position on the map.

My problem is that I'm not sure how to determine the direction the car is facing and how to display it on the map. I want the car to point in the direction it's heading, and I want it to rotate when the user rotates the map. Can someone please guide me on how to achieve this? I'm currently stuck and any help would be appreciated.

The API response

[
    {
        "lat": 33.642853,
        "lng": 72.92199,
        "speed": 10.0,
        "refDist": 0.148,
        "accStatus": "ON",
        "recDateTime": "Apr 4, 2023 2:31:35 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    },
    {
        "lat": 33.643696,
        "lng": 72.92078,
        "speed": 10.0,
        "refDist": 0.098,
        "accStatus": "ON",
        "recDateTime": "Apr 4, 2023 2:32:08 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    },
    {
        "lat": 33.644466,
        "lng": 72.91964,
        "speed": 8.0,
        "refDist": 0.185,
        "accStatus": "ON",
        "recDateTime": "Apr 4, 2023 2:32:33 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    },
    {
        "lat": 33.645203,
        "lng": 72.91854,
        "speed": 8.0,
        "refDist": 0.304,
        "accStatus": "ON",
        "recDateTime": "Apr 4, 2023 2:33:03 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    },
    {
        "lat": 33.646107,
        "lng": 72.91741,
        "speed": 9.0,
        "refDist": 0.285,
        "accStatus": "ON",
        "recDateTime": "Apr 4, 2023 2:33:34 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    },
    {
        "lat": 33.662758,
        "lng": 72.88765,
        "speed": 19.0,
        "refDist": 0.516,
        "accStatus": "On",
        "recDateTime": "Apr 4, 2023 2:41:34 PM",
        "drivingStatus": "Moving",
        "StatusTime": "02:02:00",
        "driver": "test",
        "temperature": 0.0,
        "Imoblize": "Normal"
    }
]
wahab sohail
  • 161
  • 1
  • 12

0 Answers0