Home > other >  Cities missing in Google Maps API distance matrix
Cities missing in Google Maps API distance matrix

Time:11-10

I have been using the Google Maps API's distance matrix. However, this seems to not be working for some cities and I'd need your help to figure out why / what I'm doing wrong.

Here's what I'm typing to find the distance between Paris (France) and Amsterdam (NL) in train:

https://maps.googleapis.com/maps/api/distancematrix/xml?destinations=Paris&language=en-EN&mode=transit&transit_mode=train&origins=Amsterdam&key=XXX

I've replaced my API key by XXX on purpose here.

Here's what I'm getting in return:

\<DistanceMatrixResponse\>

    \<status\>OK\</status\>

    \<origin_address/\>

    \<destination_address\>Paris, France\</destination_address\>

    \<row\>

        \<element\>

            \<status\>NOT_FOUND\</status\>

        \</element\>

    \</row\>

\</DistanceMatrixResponse\>

For some reason the <origin_address/> is blank and I can't figure out why.

Thanks :)

CodePudding user response:

Amsterdam (by itself) can't (currently) be found.

Amsterdam, Netherlands (assuming that is what you are looking for) can.

Seems like a data issue.

https://maps.googleapis.com/maps/api/distancematrix/xml?destinations=Paris&language=en-EN&mode=transit&transit_mode=train&origins=Amsterdam,Netherlands&key=MY_API_KEY

returns:

<DistanceMatrixResponse>
<status>OK</status>
<origin_address>Amsterdam, Netherlands</origin_address>
<destination_address>Paris, France</destination_address>
<row>
<element>
<status>OK</status>
<duration>
<value>12000</value>
<text>3 hours 20 mins</text>
</duration>
<distance>
<value>525025</value>
<text>525 km</text>
</distance>
</element>
</row>
</DistanceMatrixResponse>
  • Related