Geocoder.getFromLocation() returns addresses in arabic - android

Im using Geocoder on Android devices from Israel. Up until a few weeks ago everything worked fine and when i was doing reverse geocoding all addresses were received in hebrew. But at some point i started getting the same addresses in arabic.
This is a sample code im running (the lat/lon is in Tel-Aviv) :
Geocoder geocoder = new Geocoder(mContext, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(32.087765863162346, 34.781454205513, 1);
When i inspect 'addresses' i get the following printout :
[Address[addressLines=[0:"عمنوئيل هرومي 26",1:"Tel Aviv",2:"Israel"],feature=26,admin=null,sub-admin=null,locality=Tel Aviv,thoroughfare=عمنوئيل هرومي,postalCode=null,countryCode=IL,countryName=Israel,hasLatitude=true,latitude=32.0877767,hasLongitude=true,longitude=34.7813859,phone=null,url=null,extras=null]]
Please note that the devices are not localized to israel. meaning, Locale.getDefault() has "US" and "en" as country and language codes.
I already opened a bug in the Geocoder issue tracker - http://code.google.com/p/gmaps-api-issues/issues/detail?id=6182 - but was referred to the Android issue tracker. Opened another one over there - https://code.google.com/p/android/issues/detail?id=64382 - but it seems like the bug is not even in the android device side but in the Geocoder backend service. So im in a dead end.
I'd appreciate if anybody that knows anybody that knows someone from the responsible team in Google will let them know. Thanks.
EDIT: since i sense that questions posted here that are not exactly formed as questions are not very appreciated, let me rephrase - Does anyone know an issue tracker where its possible to open an issue regarding the android Geocoder backend service ? Again, thanks.

I had the same problem and I fixed it by setting a Locale in the Geocoder init,
you can do something like this:
Locale lHebrew = new Locale("he");
Geocoder geocoder = new Geocoder(this, lHebrew);
Let me know if the problem has been solved.

Related

android Geocoder throws IOException: Service not Available

after removing firebase analytics, ads and crashlytics (and google-services.json), I get the following error:
java.io.IOException: Service not Available
Code:
Geocoder gcd = new Geocoder(context, Locale.getDefault());
final List<Address> addresses = gcd.getFromLocation(latlng.latitude, latlng.longitude, 1);
I don't find any explanation why this happens... Anyone here who can help me?
There is no APIKey to appy or something, right?
PS: My maps fragment is working (com.google.android.geo.API_KEY meta-data in manifest is used)
I'm running OnePlus One, Android 8.1.0 (aosp_bacon-8.1.0-20180331.agentfabulous) and gapps mini.
Seems to be a problem with my phone. I will implement this.
I'm going to close this thread.
Yes u need geocoding api key:
When i used have same problem my solution was restart phone but from reserch then i found couple solution about that.
Recreate api key
Api key get limit or bugeed
Use other for check is it blame of full service or not
Move one part to other project and check does it work if yes that meen it's problem in code somew here

Using Open Weather Map APi

I have contacted Open Weather Map support team last week and their forum is dead. Hopefully get some help on here.
I am currently building a weather app for android.
when I send the lat and long for Birmingham UK
which are
lat 52.4447615﹕
lon -1.9292798
it returns Vietnam as the country with a completely different lat lang? I know open weather map is very popular so I must be constructing the url wrong or
something.
http://api.openweathermap.org/data/2.5/weather?q=lat=52.4447462&lon=-1.9292798&units=metric
would really appreciate any help. Thanks,
Matt
It seems the problem is the units argument. Just get rid of it and it works:
http://api.openweathermap.org/data/2.5/weather?lat=52.4447615&lon=-1.9292798
Please note I have not read through the API documentation, just started from their overview page here:
http://openweathermap.org/current.
Try this : [openweathermap.org]1
You can also use Geocoder to get city name from co-ordinates.

How to make an autocomplete address search text box that retrieves the same result as Android Maps?

I've created an autocomplete address search text box. My problem is that I just can't make it work fine:
Addresses are out of the bounding box usually, whatever I do - this didn't help.
Finds addresses that doesn't contain the typed text.
Finds less addresses, than max but it doesn't contain the good result.
The result list is totally irrelevant sometimes.
I need to type almost the whole address to get the correct result.
Source:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
try {
if (Geocoder.isPresent()) {
// Bounding box: Hungary
addresses = geocoder.getFromLocationName(text, 5, 46.13, 21.96, 48.89, 16.69);
}
} catch (IOException e) {
Log.v(tag, "Geocoding error: " + e.getMessage());
e.printStackTrace();
}
My aim is to make an address search text box which gets the same result as in Android Maps seach text box - except the previously typed/favourite addresses and etc., which is an other story.
The Google Places Autocomplete API may be of help. As far as I know you must license it for use in commercial apps. If your app is for free then you should be fine.
EDIT about inaccurate Geocoder results:
I haven't yet played around much with Geocoder. But what I can tell you so far is the following:
You need to take into consideration that on some devices all methods return null (check Geocoder.isPresent() to be sure) because Geocoder relies on some underlying implementation that can be missing on some devices.
And it is also possible that these results come from an other Geocoder engine / service than Google Places.
On top of that the query results are never perfect. You rarely get the exact address of the current location either because the location is off or because the Geocoder data is not accurate enough (or simply outdated).
If you really need an accurate address you should give the user both a list of best candidate options and some means for manually editing the address.
If you need more accurate results based on the location name you could take a look at available online services that perform better for your needs. One example is geonames.org. If their database is good enough for you, then you need to get or implement some Java API for interfacing with the service of your choice and use that instead Geocoder.

Android Geocoder doesn't detect highways / interstates?

I'm using getThoroughwayfare() to get street names but when on a highway / interstate the method returns null. I couldn't find another method that could detect interstates. Has anyone been able to successfully detected interstates?
Thanks
Ok, Its quite old question, but i think i answer for somebody else.
I too need to get information whether i was on interstate or not and Geocoder was of no help.
So i came across Google geocode api which gives plenty of information.
e.g
LatLng: 39.249121,-122.182131
And Url would be:
https://maps.googleapis.com/maps/api/geocode/json?latlng=39.249121,-122.182131&sensor=false
sensor is true in case you sending from mobile and false if using browser.
Now you can open the link and check the detailed reply for yourself, in those json objects, you will get a type = route and you will get I-5 as the short_name of road you are on.

Android Geocoder - different results when called from different geographical locations

I have the following code in my Android program
List<Address> addressList = geoCoder.getFromLocation(37.790551,-122.433931, 1);
if (!addressList.isEmpty()) {
address = addressList.get(0);
String number = address.getSubThoroughfare();
String streetName = address.getThoroughfare();
.....
}
This is a request to essentially get a street name (hence the 1) from a latitude and longitude in San Francisco.
When I execute this program on a phone in Europe (specifically Ireland) number is returned as 2250-2290 and streetname is returned as Fillmore St.
When I get a friend to run the same code on his phone in California number is null and streetname is still Fillmore st.
I've seen other SO questions allude to region settings but is this possible that the geographical location can affect the query in the Android API?
The Javascript Geocoding API mentions region bias. I wonder is it possible to do something similar in the Android API. I did try creating the Geocoder as
Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.US);
but this does not re-recreate the California based result.
From getting people to run identical code on different continents it seems that location is indeed a factor.
The Javascript geocoding allows you to specify a region though
Are the phones running different versions of android? Also, another thing to keep in mind is that "The Geocoder class requires a backend service that is not included in the core android framework." So, if the two phones are calling upon different backend services to query for the Geocoder, that may explain the output you are seeing.
I think with Android 1.5, they included a Google API backend service implementation for Geocoder. I don't know if newer versions of Android and the Google API made changes to the Geocoder implementation that may be giving you different results or it's coming from some other backend service.

Categories

Resources