Reverse Geocoding

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Reverse Geocoding

Postby sendhilgb » Tue May 05, 2009 6:08 am

Hi

I am trying to get the location details by providing the latitude and longitude to the Geocoder class API's . can any one help me with it

Code snippet

locationNames=geocoder.getFromLocation(latitudeDouble,longitudeDouble,1);

I have given the Internt permissions and resolved the proxy settings.

Getting java.io.IOException : Unable to parse response from server
sendhilgb
Freshman
Freshman
 
Posts: 6
Joined: Mon Apr 20, 2009 9:33 am

Top

Re: Reverse Geocoding

Postby fbesoain » Sat May 09, 2009 7:22 pm

sendhilgb wrote:Hi

I am trying to get the location details by providing the latitude and longitude to the Geocoder class API's . can any one help me with it

Code snippet

locationNames=geocoder.getFromLocation(latitudeDouble,longitudeDouble,1);

I have given the Internt permissions and resolved the proxy settings.

Getting java.io.IOException : Unable to parse response from server


hi sendhilgb,

do you declare:

Geocoder gc = new Geocoder(this, Locale.getDefault());

so now you can use:

gc.getFromLocation(latitudeDouble,longitudeDouble,1);

but this sentence return a list with the address , so you need use a list like this:

List<Address> addresses = gc.getFromLocation(lat, lng, 1);

i hope that information might help you,

best,
fbesoain
Freshman
Freshman
 
Posts: 6
Joined: Wed May 06, 2009 2:29 am
Location: Chile

Postby sendhilgb » Mon May 11, 2009 6:15 am

Thanks it works :)
sendhilgb
Freshman
Freshman
 
Posts: 6
Joined: Mon Apr 20, 2009 9:33 am

Postby fbesoain » Mon May 11, 2009 10:58 pm

sendhilgb wrote:Thanks it works :)


is very funny , because I wrote a code tying to do the same, but isn't working I dont know for why!

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  Geocoder gc = new Geocoder(this, Locale.getDefault());
  2.         try {
  3.           List<Address> addresses = gc.getFromLocation(lat, lng, 1);
  4.           StringBuilder sb = new StringBuilder();
  5.           if (addresses.size() > 0) {
  6.             Address address = addresses.get(0);
  7.  
  8.             for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
  9.               sb.append(address.getAddressLine(i)).append("n");
  10.  
  11.             sb.append(address.getLocality()).append("n");
  12.             sb.append(address.getPostalCode()).append("n");
  13.             sb.append(address.getCountryName());
  14.           }
  15.           addressString = sb.toString();
  16.         } catch (IOException e) {}
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I was reading about sometimes isn't possible find the location with the georeference ... do you have some points to test?

thanks,
fbesoain
Freshman
Freshman
 
Posts: 6
Joined: Wed May 06, 2009 2:29 am
Location: Chile

Postby camv » Wed Oct 28, 2009 5:03 pm

I'm trying the same code as fbesoain and it is not working. I bought a Android book where this code is printed, but I guess there is something missing to get it to work.

Do anyone know whats wrong?

I'm testing my app on an 1.5 AVD emulator. When i look at the debug log it seems like the code doesn't do the lookup, thus addresses.size() returns 0.
camv
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Oct 28, 2009 4:57 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests