In my town, recently a delivery company has been opened (think DoorDash but on a much smaller scale and only doing local deliveries). Now what really confuses me is that they charge pennies for each delivery and they offer a quite smooth delivery tracking feature. Now, I know for a fact that they are using Google’s API for tracking the deliveries and from what I could find on Google, this comes out to ~5$ per 1000 requests. Okay let’s do some math

The exact delivery cost comes to around 1-3e depending on the distance. To obtain the desired smoothness of the tracking feature, you need to update the courier’s location at least every second. Suppose the delivery takes 15 minutes. This is 900 requests, or 4.5$ just for the delivery tracking. Clearly infeasible!

I thought about how I would optimise this and I came up with one not so perfect solution. Namely, you would deliberately have 5 second latency between the actual location and the last received location, and you would display courier moving with constant speed in the last 5 seconds, until you get the next location. This would significantly decrease the number of sent requests and also 5 seconds latency is not a lot, but I am sure there has to be a better way.

Am I completely missing the point of how Google maps API works, or is there a more clever way to resolve this?

Thank you for your input on this.

  • You're assuming a sample rate of once per second; I doubt it's this granular. Tracking apps typically update themselves once per minute, which is 15 requests in your example. May 11, 2022 at 21:23
  • Well, this assumption comes from the fact that the UI was quite smooth and one cannot easily predict the movement over a minute. Note that I suggested a similar solution, namely predicting the constant movement, but we can do that over the course of 5 seconds, but over a minute, I am not so sure. Thanks for the comment May 11, 2022 at 21:25
  • And yes, you can do some interpolation to smooth things out a bit. May 11, 2022 at 21:26
  • Consider that typical map instructions over a reasonably short distance have very few turns in them, maybe 10 or less. If you know how fast a driver is travelling over one segment, you can make some guesses about where their car will be ten seconds from now, or even thirty, even with turns. You can adjust your guesses every 30 seconds so that it fixes itself if the driver makes a wrong turn. May 11, 2022 at 21:28
  • This is especially true if you have real-time traffic information, like Google Maps does. They have this information because a significant percentage of the drivers on a given street are also running Google maps, and Google is tracking them also. May 11, 2022 at 21:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.