T tonycmac Member Licensed User Longtime User Mar 1, 2012 #1 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!
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!
Erel B4X founder Staff member Licensed User Longtime User Mar 1, 2012 #2 Can you post a link to their API description? Upvote 0
T tonycmac Member Licensed User Longtime User Mar 1, 2012 #3 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
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:
NJDude Expert Licensed User Longtime User Mar 1, 2012 #4 Can you post your project?, use the EXPORT TO ZIP in the designer. Upvote 0
T tonycmac Member Licensed User Longtime User Mar 1, 2012 #5 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
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...
NJDude Expert Licensed User Longtime User Mar 1, 2012 #6 The attached file is a bare bones project to use Google's geo Location, it's based on the tutorial you mentioned. Attachments GeoLocation_Sample.zip GeoLocation_Sample.zip 7.2 KB · Views: 923 Upvote 0
The attached file is a bare bones project to use Google's geo Location, it's based on the tutorial you mentioned.
T tonycmac Member Licensed User Longtime User Mar 1, 2012 #7 Exactly what I was looking for!! Time for me to learn how to parse XML now! :sign0098: Upvote 0
mmieher Active Member Licensed User Longtime User May 13, 2012 #8 Thank you! I have been trying to do this for two days! Upvote 0
netchicken Active Member Licensed User Longtime User May 14, 2012 #9 Fantastic! Something I have always wanted! Upvote 0
rbsoft Active Member Licensed User Longtime User May 14, 2012 #10 You could also use the Geocoder library. http://www.b4x.com/forum/additional-libraries-official-updates/17115-geocoder-library.html#post97857 Rolf Upvote 0
You could also use the Geocoder library. http://www.b4x.com/forum/additional-libraries-official-updates/17115-geocoder-library.html#post97857 Rolf