Geocoder getFromLocationName is not returning anything if I'm searching for business places. Here are my finding so far:
grocery places, commercial buildings -> no result
schools -> finding results, but only returning Latitude and Longitude. I have to do reverse geocoding in order to get the address based on the coordinates, but the address wouldn't be accurate.
complete address -> same as school, only returning Latitude and Longitude
hospital and pharmacy -> returning Latitude and Longitude
I've tested this on 1.6, 2.1 and 2.2 devices that has Google Maps.
I'm trying to find if there's a limitation explained somewhere on the SDK, but there is none except:
The amount of detail in a reverse
geocoded location description may
vary, for example one might contain
the full street address of the closest
building, while another might contain
only a city name and postal code. The
Geocoder class requires a backend
service that is not included in the
core android framework. The Geocoder
query methods will return an empty
list if there no backend service in
the platform
(http://developer.android.com/reference/android/location/Geocoder.html)
[update]
So after nights of research, I can't seems to make it work - Google simply wont give me the result. Some discussion on android-developers points a fact that getFromBusinessName was omitted when Google Navigation came out. So I'm starting to assume that Google is pulling back some of their geocoding service.
I can always create a webpage that use Google Geocoder API, but its limited to 2500 api call - and I dont think it will be legal (lol). So what are my alternatives here?
I've hit the same problem. I'm finding that the geocoding API often returns no results if I include the business/venue name, but by missing it off, the lat/long can be much less accurate.
I've implemented a pragmatic solution:
1. Call the API with a string including the business/venue name
2. If it fails, call it a second time without the business/venue name, just the address
I've yet to see a case where no location is returned, so it seems a decent compromise as it means I do at least get location data, if sometimes less accurate, and the cost of a second API call is mitigated with threaded calls.
I couldn't find the button to reply but, like you all, I have just run into the same problem. I haven't tried it yet but it sounds pretty solid. A potential workaround is located here:
Using Google Maps API to get Address of Business
Happy coding :)
Edit: Forget that link and check this one out: http://code.google.com/apis/maps/documentation/places/
Try this approach:
1) Use Geocoder to convert latitude-longitude to address
2) Make an API call to Whitepages (or similar service), specifically the reverse_address method which will get you business name for the address mentioned.
Related
http://maps.google.com/maps/api/geocode/json?sensor=false&address=
I was looking at the above api and trying to find the location of the address "Grand Copthorne Hotel"..
However the result I am getting in the api is as follows
"status" : "ZERO_RESULTS"
Please let me know why this is taking place as it is affecting my entire platform and if its a problem from your end when should I expect the issue to be solved
Please let me know about the above issue
Geocoding API filters out businesses, it works only with street addresses.
If you need the location of the business you have to use Places API search.
E.g.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Grand%20Copthorne%20Hotel&key=YOUR_API_KEY
Please refer to the documentation for further details:
https://developers.google.com/places/web-service/search
The Google Geocode API filters out businesses and only works on addresses. You said you have a valid address, but "Grand Copthorne Hotel" is not a valid address. An address provides enough information to mail something to a specific person or business.
If you want to retrieve location information with a generic search term, you should use a different API.
You can try some searches in the Google Places API search box; maybe that is a good API for your situation. It returns lots of information, including latitude and longitude. Check out the documentation.
The first thing you should do is discover and decide what kind of API you actually need. Do you need information for product shipping? Do you need to show a map to a user? Do you need to retrieve businesses' information?
Keep in mind that there are many kinds of location searches and varying services that return latitude and longitude. For instance, there is geocoding (generally matches addresses or partial addresses to a fairly accurate latitude and longitude pair); there is address validation (matches addresses to a database of information—probably postal service information—to provide very accurate location information for real addresses); there is places search (search for names, icons, titles, or business terms and retrieve location information). There are still other options. Just take a look at one list of mapping-related APIs from Google...
Full disclosure: I work for SmartyStreets, an address validation service.
In my android app, I find the address of locations using Geocoder.getFromLocation(). I can get an Address object and get the address lines of an address with Address.getAddressLine().
I am only interested in the first address line, which I can get easily with Address.getAddressLine(0).
Also, app allows user to choose locations using PlaceAutocomplete. When user chooses a location, I receive a Place object and I can get the address by Place.getAddress().
The problem is, Place.getAddress() returns a string instead of an Address object. This string contains the full address, so I cannot easily get the first address line, as I did with Address object.
How should I find the first address line from string returned by Place.getAddress()?
Short answer is that you can't get structured data from that API. For some reason, Google has decided that is not something people would want on Android.
A colleague of mine has logged this issue with Google to request the same level of information as is provided to iOS and JavaScript users:
Issue 10019: Expose address components in Place object
Longer answer is that your options are:
You figure out a clever way to parse that string. Unfortunately the actual street/suburb/town/province structure is not consistent across different areas (e.g. Cape Town in South Africa has a different sentence structure to Johannesburg in South Africa). So your parsing rules need to be very clever.
You use a different Google API. The JavaScript API provides structured data for the related call. This related question shows more details on that API. Unfortunately Google recommends against using this technique.
I believe that Google only intends to give us this sentence for the purposes of picking an address, rather than for us to get structured information about the address. In order to get better information, you need to get the lat/lng values by querying the place ID.
From those lat/lng values, you can then reverse-geolocate to get the correct address.
Unfortunately in this technique, Google's APIs fail us once more.
often you can take address A, resolve it to a given lat/lng, and resolve that to another address B, which might be close to A, but is not. The API calls are not commutative as one would expect
I have had a fair amount of experience with these calls, and I wish there was another answer I could provide. If you wish to stick with Google's location APIs, then you can't get what you are asking for.
Now it is impossible with this API only.
But you can use Geocoder with latitude and longitude from Place object
Note: This information was observed at this post. Repeated below.
Actually you can achieve this, you will just need to use the GeoCoder to do the lookup. Then simply use the Address object to get the data you need.
Here is some Java code to showcase the solution.
List<Address> addresses = null;
addresses = geocoder.getFromLocation(latitude, longitude,1);
if(addresses != null && addresses.size() > 0 ){
Address address = addresses.get(0);
// Thoroughfare seems to be the street name without numbers
String street = address.getThoroughfare();
}
I'm developing a android application that uses the user location to show a list of street name suggestions around their coordinates, since location retrieval is not going to be accurate enough, and in my application i need the best accurate position.
I tried a lot of approaches, tested google reverse geocoder, but it only gives me only one address, i tried google places api but it's not intended to return addresses, but places, what's not i'm lookin for, i tried findNearBy streets of geonames, but it only gives me street names, i need full data of the streets, like, city, state, country... i tried to use both geonames and google geocoder, getting a list of names, and converting each name into reverse geocoder request, but some street names are also available in another countries, i dont know how to specify a name and a latlng in geocoder request to filter results near specific coordinate.
I tried apis on server-side, which is a django-python server, the scenario is: the user sends their coordinate to server, which will use user location to request to another api's and format the result to the android, but didn't manage to found a good and fast solution.
I've seen a lot of some similar questions on SO but none had the answers I am looking for.
I am trying to build a location based application which shows google map and allows the user to search a location by writing an address (as google maps does).
I have been trying to use android's geocoder to do this, and it finds some addresses. However, one of the first addresses that i tried (vaasankatu, helsinki, finland), it didn't find when I searched by street name (vaasankatu). Also one other street name that I have tried does not return any results. If I add the city (helsinki), or the country (finland) after the street name, then geocoder finds addresses.
Google maps web app and android app find the addresses without any problem just by searching by the street name. I am wondering whether I could somehow make geocoder to return the address when it is searched by the street name? I could of course try to find out the current city with the geocoder and attach it after the query, but this seems a bit like a hack, is there a better way?
I am also a bit worried about the geocoder documentation, which says:
"The Geocoder class requires a backend service that is not included in
the core android framework. The Geocoder query methods will return an
empty list if there no backend service in the platform. Use the
isPresent() method to determine whether a Geocoder implementation
exists."
I don't quite understand what that means.. So is there a big portion of phones that don't support geocoder? The text seems to suggest there might be, but why would there be such an api then at all..? Should I use another api alltogether? Is, for example Google geocoding api for web services usually used? Or places api?
I have an android app that is adding places to the google Places API without problem. My app also receives places added by other users.. To my dismay, I realized that when adding a place, there is no way to include an address, only a longitude and latitude. I had suspected that Google would supply an address when the place was requested, but alas, the "vincinity" value is not included in the JSON returned from good on this location.
I suppose I could take the lat and lng and subsequently geocode (reverse-geocode?.. I can't ever keep them straight) the results myself, but was wondering if there was something I was overlooking.. I have read all the Places API docs through several times.. I thought if anyone knew a little trick, they would be on this website (of course).
The 'vicinity' parameter will only be returned after the Place Report Request has been moderated.
Currently only Place Report Requests submitted from a small number of trusted applications are being moderated for integration into Google Places. We are still working on streamlining the moderation process to minimise spam, incorrect and duplicate place results.
The best option would be to reverse geocode the returned lat lng.