Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Distance Matrix wrong result

I am performing a request to the Google Maps Distance Matrix API to calculate the distance from one point to another. Both points are in Russia. The problem is that, in some cases, the API returns the wrong destination.

For example, I select this point on the Black sea coast, Russia.

The request to the API is
https://maps.googleapis.com/maps/api/distancematrix/json?origins=58.3941198,33.223535&destinations=44.58019749055891,38.0705451965332&mode=driving&language=ru-RU&key=

It returns

"destination_addresses" : [
  "1 Chome-11 Kamifukubara, Yonago-shi, Tottori-ken 683-0004, Japan"
],...

So, Google Maps knows it is Russia, but Distance Matrix thinks it is Japan. Why?

Is there a known bug for places near the sea coast?

UPDATE

This bug was handled in issue tracker https://issuetracker.google.com/issues/35828610. It was marked as Fixed on July 19, 2016.

like image 261
shukshin.ivan Avatar asked May 04 '16 12:05

shukshin.ivan


People also ask

How does Google Distance Matrix work?

The Distance Matrix API provides travel distance and time for a matrix of origins and destinations, and consists of rows containing duration and distance values for each pair. Distance Matrix is available in several forms: as a standalone API. as part of the client-side Maps JavaScript API.

Is Google Distance Matrix API free?

The Distance Matrix API uses a pay-as-you-go pricing model.


2 Answers

Good news and bad news :)

The bad news is that the Japanese address will come up for many remote locations, as this is an on-going issue in the Geocoding API. This has been reported in the Google Maps API issue tracker: https://code.google.com/p/gmaps-api-issues/issues/detail?id=9683

Take a look at this comment on the issue tracker for details on how to workaround this.

The good news is that you still get the correct distances and route from Distance Matrix API and Directions API.

like image 53
miguev Avatar answered Sep 20 '22 11:09

miguev


The problem with this Japan location is its bounds which say it is all around the world:

"formatted_address" : "1 Chome-11 Kamifukubara, Yonago-shi, Tottori-ken 683-0004, Japan",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 90,
              "lng" : 180
           },
           "southwest" : {
              "lat" : -90,
              "lng" : -180
           }
        },
        "location" : {
           "lat" : 35.4426127,
           "lng" : 133.3638089
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 90,
              "lng" : 180
           },
           "southwest" : {
              "lat" : -90,
              "lng" : -180
           }
        }
     },
     "place_id" : "ChIJlwBC99P3VjUReuUmCg7qU_E",
     "types" : [ "sublocality_level_3", "sublocality", "political" ]
like image 39
FelixW Avatar answered Sep 20 '22 11:09

FelixW