Geocoder

Put your problem here if it does not fit any of the other categories.

Geocoder

Postby droid12 » Thu Feb 14, 2008 4:01 pm

When I look at the Geocoder class, I see a way to do reverse geocoding (lat/lon to address), but not a way to do normal geocoding (Address to lat/lon). I can't find any examples - anyone figure this out?
droid12
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 25, 2008 5:59 am

Top

Postby plusminus » Thu Feb 14, 2008 4:11 pm

Hello droid12,

should be working like this, but it doesn't...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Address[] as = new Geocoder().getFromLocationName("1600 Amphitheatre Parkway, Mountain View, CA",double centerLatitude, double centerLongitude, double latitudeSpan, double longitudeSpan);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Could you get any of the GeoCoding actually work :?: (anything I try returns null) :(

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby droid12 » Thu Feb 14, 2008 4:22 pm

I have not tried coding yet - just looking at the APIs. I will play around and post results later.

In your example below, what if you don't have lat/lon or span - only an address? Do you span the continent and center in Kansas? :)

Thanks!
droid12
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 25, 2008 5:59 am

Postby droid12 » Thu Feb 14, 2008 6:29 pm

I tried a number of examples with getFromLocationName and I get null returned in all cases. If anyone gets this to work - please post!
droid12
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 25, 2008 5:59 am

Postby res » Thu Feb 14, 2008 8:27 pm

If you try and access the Address[] straight away it will be null since the emulator hasn't had time to get the information to populate it yet. If you view the emulator logs after you make a query you will see something like

D/LocalGeoCoder( 769): Got Address ( AND THEN ALL THE INFORMATION ABOUT THE ADDRESS)

other replies are

D/LocalGeoCoder( 769): Got locatin query ( AND THEN ALL THE INFORMATION ABOUT THE LOCATION)
D/LocalGeoCoder( 769): Got business query ( AND THEN ALL THE INFORMATION ABOUT THE BUSINESS)


I presume you will need to catch this via your intent reciever so you know when its ok to try and read information from the Address[]. Haven't got this far yet, need to find more spare time.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby plusminus » Fri Feb 15, 2008 11:22 am

Hey guys,

droid12 wrote:In your example below, what if you don't have lat/lon or span - only an address? Do you span the continent and center in Kansas? :)

That was just for example (therefore I left the "double"-types also).
Posted to the Google Groups also:
http://groups.google.com/group/android- ... 1016ced1e0 but no reply yet...
(getting no reply happens far to often :x )
droid12 wrote:I tried a number of examples with getFromLocationName and I get null returned in all cases. If anyone gets this to work - please post!

Damn I love new praised features that are not working...
res wrote:If you try and access the Address[] straight away it will be null since the emulator hasn't had time to get the information to populate it yet. If you view the emulator logs after you make a query you will see something like

D/LocalGeoCoder( 769): Got Address ( AND THEN ALL THE INFORMATION ABOUT THE ADDRESS)

other replies are

D/LocalGeoCoder( 769): Got locatin query ( AND THEN ALL THE INFORMATION ABOUT THE LOCATION)
D/LocalGeoCoder( 769): Got business query ( AND THEN ALL THE INFORMATION ABOUT THE BUSINESS)


I presume you will need to catch this via your intent reciever so you know when its ok to try and read information from the Address[]. Haven't got this far yet, need to find more spare time.

So you managed it :?: :D
Could you explain what you mean with the Intent and IntentReceiver issue :?: I can see no parameter where we can place an Intent ... :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby res » Fri Feb 15, 2008 4:32 pm

plusminus wrote:So you managed it :?: :D
Could you explain what you mean with the Intent and IntentReceiver issue :?: I can see no parameter where we can place an Intent ... :?:

Regards,
plusminus


You know how with the GPS location update we use 'android.intent.action.LOCATION_CHANGED' for our IntentReceiver whenever this action occurs? Then we act on this intent by updating our gps location.

You need to add another action to your intent receiver class so you can act upon it. I've look briefly but can't find what action we need to use for the geocoder response, is their someway we can act on all/blank intents?

Hope this makes sense, if we can find the action required I can post up working code.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby plusminus » Fri Feb 15, 2008 6:38 pm

Hello res,

res wrote:You know how with the GPS location update we use 'android.intent.action.LOCATION_CHANGED' for our IntentReceiver whenever this action occurs? Then we act on this intent by updating our gps location.


But there we could register ourselves t be informed of a Location-Change, this is probably something different.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby res » Fri Feb 15, 2008 8:59 pm

Hmm, well their has to be a way to figure out when the search has finished. It isn't practical in your thread to continually check if Address[] is null before proceeding to the next step. I'm going to hack mine up this way for now until a better solution comes along.

I was hoping an Event would be fired once the search is complete, this would be a much nicer approach.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby res » Sat Feb 16, 2008 12:23 am

Hmm, when calling a geocoder method you get output in logcat but Address[] continues to be null, so I guess its not working or some step we are missing?

This is really frustrating :(
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby plusminus » Sat Feb 16, 2008 3:01 pm

Hello res,

frustration is a really good buzzword here :?
res wrote:...This is really frustrating :(


Would be fine if we could pass a Handler or sth. similar to the function that "gets called" when geocoding failed or is finished...

I'll post here if I hear of solutions and changes.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby res » Sat Feb 16, 2008 11:22 pm

plusminus wrote:Would be fine if we could pass a Handler or sth. similar to the function that "gets called" when geocoding failed or is finished...


I have tried this but nothing happens since Address[] is always null so you can never get any information.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby droid12 » Sun Feb 17, 2008 8:40 pm

I found some additional information here:

http://groups.google.com/group/android- ... 9fa1d3ffa1

Why do they advertise these APIs if they aren't ready... what good does it serve?
droid12
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 25, 2008 5:59 am

Postby plusminus » Sun Feb 17, 2008 8:50 pm

Hello droid12,

droid12 wrote:Why do they advertise these APIs if they aren't ready... what good does it serve?

Except of making us (at least me) :x and :shock: ... no sense!

But anyway, thanks for providing the link. :)

This is said to work really fine (or at least worked up to yesterday o_O ):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. GmmGeocoder geocoder = new GmmGeocoder(Locale.getDefault());
  2. Address[] addresses = geocoder.query(searchQueryString, GmmGeocoder.QUERY_TYPE_LOCATION, 0, 0, 180, 360);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


So expect a tutorial on geocoding tomorrow :)

Regards,
plusminus :shock:
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby droid12 » Wed Feb 20, 2008 3:11 pm

Is it just me, or did the GmmGeocoder stop working yesterday? When I try to use it today I get:
Host is unresolved www.google.com:80. The browser works fine...

I was really having a great time for the 2 days it worked... :) :cry:
droid12
Freshman
Freshman
 
Posts: 7
Joined: Fri Jan 25, 2008 5:59 am

Top
Next

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests