Directions API picking the wrong city

676 Views Asked by At

So, take a look at the results for this:

http://maps.googleapis.com/maps/api/directions/json?origin=2160%20Barnes%20Ave,%20Bronx,%20NY&destination=2160%20Barnes%20Ave,%20Bronx,%20NY&sensor=false

In cleartext:

  • Origin: 2160 Barnes Ave, Bronx, NY
  • Destination: 2160 Barnes Ave, Bronx, NY

When I do the search, it returns:

  • 2160 Barnes Ave, Mt Vernon, NY

I'm highly suspect this is not expected behavior.

When I try the address in Google Maps, I get the correct location, so the address exists I'm not typing it wrong. https://maps.google.com/maps?q=2160+Barnes+Ave,+Bronx,+NY

Now look what happens when I search for the same street adding a "near Bronx, NY" clause:

http://maps.googleapis.com/maps/api/directions/json?origin=2160%20Barnes%20Ave,%20Bronx,%20NY%20near%20Bronx,%20NY&destination=2160%20Barnes%20Ave,%20Bronx,%20NY&sensor=true

Is there something I'm doing wrong? As of now, I feel like I would have to search for:

{Address}, {City}, {State} near {City}, {State}

If I put the zip code, it works fine, but I won't always have the zip code available.

Google's support group says that I should use StackOverflow vs official forums. So... help?

1

There are 1 best solutions below

4
On

Change 2160 to 2162 and you're done! :-)

Working link:

http://maps.googleapis.com/maps/api/directions/json?origin=2162%20Barnes%20Ave,%20Bronx,%20NY%20near%20Bronx,%20NY&destination=2162%20Barnes%20Ave,%20Bronx,%20NY&sensor=true

This probably happens because 2160 Barnes Ave, Bronx, NY, does not exist, while 2160 Barnes Ave, Mt Vernon, NY as well as 2162 Barnes Ave, Bronx, NY do.