{
  "id": 21563263,
  "title": "The car on your ride-hailing map is a guess",
  "url": "https://urgent.news/2026/11/24/the-car-on-your-ride-hailing-map-is-a-guess",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-24T08:00:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mohamedelgohary/the-car-on-your-ride-hailing-map-is-a-guess-31om"
  },
  "original_language": "en",
  "account": "The car displayed on a ride-hailing map is not the exact location of the driver. Instead, it represents the app's best guess of where the driver is. The driver's phone sends GPS coordinates to the app every few seconds, not all the time. If the app displayed each position as soon as it arrived, the car would appear to teleport from one point to another. To avoid this, the app animates the car's movement from one reported position to the next, creating the illusion of continuous motion. Most of the time, this animation is accurate, but sometimes the car takes unexpected turns, passes through buildings, or snaps back onto the road. The app's method for guessing the driver's location depends on its own implementation. This article explains the general approach and provides a Kotlin implementation using Flow, including necessary parameters and potential issues.\n\nWhen displaying the car's position, it should not appear to be stationary at its current location. Instead, the car should be shown a few seconds behind its actual position, indicating that the displayed location is a few seconds old. This ensures that the user does not rely on the displayed position for critical decisions, such as arrival detection. Additionally, the duration of the animation is crucial. If it is shorter than the actual time between GPS updates, the car may appear to stop and start repeatedly, creating a jerky effect. Conversely, if the animation duration is too long, the car may lag behind the latest update. Therefore, the duration should not be fixed but should be calculated based on the real gaps between accepted GPS updates. These gaps can be smoothed using an exponential moving average and capped to prevent excessively slow movements caused by long periods of inactivity.\n\nNetwork conditions can affect the order in which GPS updates are received. Sometimes, multiple updates can arrive together after passing through a tunnel or after a network retry. If the animation is based on the order of arrival, the car may appear to move backward for a moment, which is visually confusing. Therefore, it is essential to use timestamps provided by the GPS device to track the exact time each update was recorded. On Android devices, the `Location.getElapsedRealtimeNanos()` method can provide a monotonic timestamp, but it is only accurate within a single boot. To address this, the server should also timestamp each update, and only the most recent timestamp should be considered valid. Any outdated updates should be discarded.\n\nMoving along a straight line between two GPS positions can cause the car to cut through buildings or other obstacles, making it appear as if it has passed through them. To avoid this, the animation should follow the actual road network instead of the straight line between two points. This process, known as map-matching, involves projecting each GPS position onto the nearest point on the road network. For known routes, this can be done by interpolating along the pre-defined route polyline. However, when the route is unknown, services such as Google's Roads API or Mapbox's Map Matching API can project the GPS points onto the road network, even though it introduces some latency and requires a network request. In cases where the route is uncertain, the map-matching algorithm should stop trusting the projected path beyond a certain distance and revert to the raw GPS position. This ensures that the car's movement remains accurate even when the map-matching algorithm makes errors.\n\nCalculating the car's heading, or direction of travel, is another important aspect of creating a realistic animation. The raw bearing provided by the GPS device can be jittery, especially when the car is stationary or moving very slowly. To create a smoother animation, the bearing should be calculated based on the path being drawn, rather than the raw GPS bearing. This bearing should only be updated when the car has actually moved a certain distance, ensuring that the animation appears smooth and natural. The provided Kotlin function `smoothAngle` demonstrates how to interpolate between the current and target bearings, ensuring that the rotation change is the shortest possible. This function takes into account the wrap-around effect of angles, preventing sudden and unnatural jumps in the car's heading.",
  "summary": "The car on a ride-hailing map is not where the driver is. It is where the app guesses the driver is. The driver's phone reports a GPS position every few seconds, not continuously. If the rider's app drew each report the moment it arrived, the car would teleport from point to point. So the app animates the car from one report toward the next, and the animation is invented. Most of the time the…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}