Reverse Geocoding

tonycmac

Member
Licensed User
Longtime User
I've created a small program based on Erel's GPS Tutorial and would like to pass the Lat/Long that the app obtains to the Google Reverse Geocoding API and display a msgbox with some information from the returned JSON or XML file.

I can't seem to figure out how to send the request to the API to get the JSON or XML file returned to the android device for parsing... :BangHead:

This seems pretty straightforward but I'm obviously missing something... Any help would be greatly appreciated!
 

tonycmac

Member
Licensed User
Longtime User
The API I'm referring to is the Google Reverse Geocoding API which can be referenced here:

The Google Geocoding API - Google Maps API Web Services - Google Code

The idea is to send a query such as this in JSON with lat/lon:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

or this in XML:
http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

which then returns parsable data...

using a desktop browser, the data shows up fine, but I'm not sure how to download this returned data and then parse the results :sign0104:
 
Upvote 0

tonycmac

Member
Licensed User
Longtime User
Unfortunately, I'm not at the computer that has the code right now but it's almost identical to Erel's GPS tutorial.

code found here: http://www.b4x.com/forum/basic4android-getting-started-tutorials/6592-gps-tutorial.html#post38535

In the GPS_LocationChanged sub, I essentially have 3 variables that come from:
Location1.Latitude
Location1.Longitude
Location1.Accuracy

When Location1.Accuracy is not equal to 0 (i.e. GPS has a fix), I then make visible a button on the screen called "Geocode".

What I'd like to do is that when the GPS has a suitable fix, send the Lat/Lon to the Google API using a URL that contains the lat/lon and have the app collect the parsable data that is then returned through a json or xml file...
 
Upvote 0
Top