Reputation: 9852
I'm trying to geocode this address "188th street & third avenue, bronx NY"
If you run this geocode query through the maps api v3 geocoder, you get back 10 or so results, none of which are in new york.
If you paste that same address into google maps, it takes you directly to the intersection in the bronx.
Is there a reason these results are inconsistent, and is there a way I can get the geocoder to give me the correct result, or at least something in the same state?
(at first i thought it was because 'third' was spelled out, so i replaced it with '3rd'. I still got 10 results with one in NYC. however, it was in queens instead of the bronx.)
Upvotes: 5
Views: 2627
Reputation: 9292
The problem is that you do not URL-encode &
in the address and use it as it is. But this &
is used for separation of URL arguments as e.g. between sensor=false&address=
. So, the data beyond &
is not considered to be part of the address. You need to replace &
in the address argument by its URL-encoding %26
:
and you will get the one correct location in New York, Bronx:
<location>
<lat>40.8588700</lat>
<lng>-73.8911250</lng>
</location>
Just for information: the Google geocoding web service uses +
for spaces in the address. Also, the recommended service URL is http://maps.googleapis.com/maps/api/geocode/
. So, you could issue as well the query:
which appears a bit simpler.
Upvotes: 9