[Python] Sometimes getting the wrong destination when using google maps distance_matrix API

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python script that uses distance_matrix from the Google Maps API (yes I know this is now legacy and replaced by routes, but I'm updating an older piece of code and don't really want to change over yet).

    My script sends a list of zip codes in Massachusetts as the origin point to get the distance to a destination.

    gmaps.distance_matrix(zips, destination, mode='driving', region='us', traffic_model='best_guess')


    90% of the time it works just fine, but occasionally it returns VERY wrong results. For example, for zip code 01033, which is Granby, MA it returns a result for Kyiv, Ukraine. If I search for 01033 in maps.google.com it correctly shows Granby. I added region='us' hoping it would try to restrain the results to the US, but no luck.

    Any idea why it does this and how to fix it?

    Continue reading...

Compartilhe esta Página