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.
http://maps.google.com/maps/api/geocode/xml?sensor=false&address=188th%20street%20&%20third%20avenue,%20bronx%20NY
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.)
To confirm the key is associated with the project: Go to the Credentials section, which can be accessed from the left side bar under Google Maps Platform > Credentials. Check that the API key you currently use on your website is listed.
According to Google's API Usage and Billing page, there is a limit of 50 requests per second. If you exceed this amount, subsequent requests to the API will fail with the OVER_DAILY_LIMIT or OVER_QUERY_LIMIT status code and the geocoded data will not be returned.
There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.
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
:
http://maps.google.com/maps/api/geocode/xml?sensor=false&address=188th%20street%20%26%20third%20avenue,%20bronx%20NY
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:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=188+street,%26+third+avenue,+bronx+NY
which appears a bit simpler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With