4
votes

We have been trying to get appropriate address in google map, but google map always ended up giving wrong latitude and longitude values with which resulted in showing up wrong address.

https://maps.googleapis.com/maps/api/geocode/json?address=1735+Vine+Street+AVALON+Hollywood+Los+Angeles+CA

We use above API with following parameters.

actual address- AVALON Hollywood, 1735 Vine Street, Los Angeles, USA

we tried with two different address format

When parameters are passed as 1735+Vine+Street+AVALON+Hollywood+Los+Angeles+CA we got values as

lat: 34.0522342,
lng: -118.2436849

When parameters are passed AVALON+Hollywood+1735+Vine+Street+Los+Angeles+CA we got values as

lat: 34.1027186,
lng: -118.3271694

Where as exact values are :

lat: 34.1027414,
lng: -118.3272224  
1

1 Answers

2
votes

There are a few problems with your request. Namely there are two important things I would like to point out:

  • Geocoding API and its use
  • Places API and how you may be interested in it

Geocoding API

I can see that in your request you are using the Geocoding API. This API is to be used with street addresses only, however you are also adding the name of the location.

Google Maps will try to do its best with the information given, but it will often be inaccurate, like in this case.

In your specific case, the request that you are sending should be using only the address1735 Vine St, Los Angeles, CA 90028.

It should look something like:

You can check your results using reverse geocoding. A good example can be found in the documentation and it is fairly useful to test your results as well:

Places API

Even then, after correcting your geocoding request, you may not get the exact coordinates you are expecting. This is because the geocoding API is not designed to point you to places, instead it merely points to street locations.

Sometimes the API does some guessing and data-combination to understand what you really want, but even that is not enough.

If you want to point people to a specific place, the service you should be using is Google Maps Places API:

To correctly use this API, you must first add the desired location to the Google Places Service (in case it is not there already).

There are many ways of doing that, to get you started I found an article that may prove to be helpful in achieving that objective:


I hope this answer gets you close to fixing your problem and google luck using the API !