Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive calls to Google Maps Distance Matrix API #25

Open
wtm17 opened this issue Jul 24, 2019 · 0 comments
Open

Excessive calls to Google Maps Distance Matrix API #25

wtm17 opened this issue Jul 24, 2019 · 0 comments

Comments

@wtm17
Copy link

wtm17 commented Jul 24, 2019

Our team noticed that using this library causes an excessive amount of calls to the Google Maps Distance Matrix API to be charged to our token and billing account.

In the current implementation, once the ETA from the server dips below 10 minutes, it starts calculating the ETA by using the Google Maps Distance Matrix API. In my testing, it is making 2 calls to Distance Matrix API every time the driver location updates. The issue stems from the MAX_LOCATION_POINTS_FOR_UPDATE variable being set to 50, which seems too low and causes multiple calls to the Distance Matrix API during a normal smooth map update.

It doesn't seem like the ETA needs to be recalculated with every driver location update. The previous eta calculation could be persisted for a certain amount of time, for example 2-3 minutes, and the eta callback could be invoked with the value of (etaTimeAtLastCalculation - timeElapsedSinceLastEtaCalculation).

I will put together a PR with this optimization. Would appreciate any feedback!

@wtm17 wtm17 changed the title Excessive calls to Google Distance Matrix API Excessive calls to Google Maps Distance Matrix API Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant