1

We are using Google distance matrix api and getting different response when using address versus coordinates for the exact same address.

When using address we don't get any information about the borough/postal town, we only get the municipality (higher level).

WITH ADDRESS

   `https://maps.googleapis.com/maps/api/distancematrix/json? 
   origins=Urban Hjärnes väg 18,168 58,BROMMA&destinations=Hantverkarg 67- 
   69,112 92,STOCKHOLM&mode=walking&language=sv-SE&key

    {
       "destination_addresses" : [ "Hantverkargatan 67, 112 31 Stockholm, 
        Sverige" ],
       "origin_addresses" : [ "Urban Hjärnes väg, Stockholm, Sverige" ],
       "rows" : [
          {
             "elements" : [
                {
                   "distance" : {
                   "text" : "8,0 km",
                   "value" : 7970
                   },
               "duration" : {
                  "text" : "1 tim 41 min",
                  "value" : 6031
               },
               "status" : "OK"
            }
         ]
      }
    ],
   "status" : "OK"
    }

` WITH COORDINATES

    `https://maps.googleapis.com/maps/api/distancematrix/json? 
   units=metric&origins=59.351563, 17.922239&destinations=Hantverkarg%2067- 
   69,112%2092,STOCKHOLM&key=

    {
    "destination_addresses" : [ "Hantverkargatan 67, 112 31 Stockholm, Sweden" ],
    "origin_addresses" : **[ "Urban Hjärnes väg 18, 168 58 Bromma, Sweden" ]** 
    ,
       "rows" : [
        {
         "elements" : [
            {
               "distance" : {
                  "text" : "7.6 km",
                  "value" : 7627
               },
               "duration" : {
                  "text" : "14 mins",
                  "value" : 824
               },
               "status" : "OK"
            }
         ]
        }
       ],
       "status" : "OK"
    }`

Even when we search with the address we want "origin_addresses" : [ "Urban Hjärnes väg 18, 168 58 Bromma, Sweden" ] instead of "origin_addresses" : [ "Urban Hjärnes väg, Stockholm, Sverige" ], which is not complete

  • It looks like the issue is not reproducible anymore. Using origin [string address](https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=18+Urban+Hjärnes+väg,+Bromma&destinations=Hantverkarg+67-69,112+92,STOCKHOLM&key=YOUR_KEY) and [coordinates](https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=59.351563,17.922239&destinations=Hantverkarg+67-69,112+92,STOCKHOLM&key=YOUR_KEY), both returns the same origin_address of "Urban Hjärnes väg 18, 168 58 Bromma, Sweden". – Angelica Aug 08 '19 at 02:26
  • We have updated the first url which was wrong. We still do not get the right origin_addresses. We expect 'Bromma' instead of 'Stockholm' as in the example with coodinates – Jörgen Holmborg Aug 26 '19 at 14:06

1 Answers1

0

I was able to replicate the issue using the ff addresses:

Correct results: "Urban Hjärnes väg 18, 168 58 Bromma, Sweden"

Urban Hjärnes väg 18
168 58 Bromma
Sweden

Incorrect results: "Urban Hjärnes väg 18,168 58 Bromma, Sweden"

Urban Hjärnes väg
Stockholm
Sweden

Notice that you can have the expected results when querying the address with proper spaces between the street number "18," and postal code "168 58". So as a workaround, you can use this sample request:

https://maps.googleapis.com/maps/api/distancematrix/json?origins=Urban+Hjärnes+väg+18,+168+58+Bromma,+Sweden&destinations=Hantverkarg+67-69,+112+92+STOCKHOLM&mode=walking&language=sv-SE&key=API_KEY

Which correctly returns the expected address:

{
    destination_addresses: [
        "Hantverkargatan 67, 112 31 Stockholm, Sverige"
    ],
    origin_addresses: [
        "Urban Hjärnes väg 18, 168 58 Bromma, Sverige"
    ],
    rows: [
        {
            elements: [
                {
                    distance: {
                        text: "8,0 km",
                        value: 7976
                    },
                    duration: {
                        text: "1 tim 41 min",
                        value: 6036
                    },
                    status: "OK"
                }
            ]
        }
    ],
    status: "OK"
}

You can also then file this issue in Google's Public Issue Tracker for their engineering team to further investigate.

Hope this helps!

Angelica
  • 687
  • 4
  • 16