Reverse Geocoding

XverhelstX

Well-Known Member
Licensed User
Longtime User
Heey everyone,

I would like to know how I would enter the latitude and longitude you received by the GPS and input it on the website and it automatically searches for it with the 'Determine adress' button, and then gets the string under it.

I guess you have to use the HTTP library, but i don't get it on how to enter and grab the string.


website: Converting Addresses to/from Latitude/Longitude/Altitude in One Step (Geocoding)

XverhelstX
 

mistermentality

Active Member
Licensed User
Longtime User
Heey everyone,

I would like to know how I would enter the latitude and longitude you received by the GPS and input it on the website and it automatically searches for it with the 'Determine adress' button, and then gets the string under it.

I guess you have to use the HTTP library, but i don't get it on how to enter and grab the string.


website: Converting Addresses to/from Latitude/Longitude/Altitude in One Step (Geocoding)

XverhelstX

It might be easier for you to try this site at Tiny Geo Coder (blog) How To Use

It does exactly the same as what you want but all you'll have to do is feed the devices gps co-ordinates. I use it in one of my gps apps, and it's as easy as....

http://tinygeocoder.com/create-api.php?g=33.790348,-117.226085

Just use replace the coordinates with your own and send this as a http request, the response is just a non html plain text page with the address as its content.

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
B4X:
url = "http://tinygeocoder.com/create-api.php?g=" & latitude & "," & longitude
' The above line generates the url to retrieve the postal adress from
request.InitializeGet(url)
request.Timeout = 20000

Sub GPS_LocationChanged (Location1 As Location)
 Latitude = Location1.Latitude ' Store the new latitude position in this string
 Longitude = Location1.Longitude ' Store the new longitude position in this string
End Sub

Sub Http_ResponseSuccess (Response As HttpResponse, TaskId As Int)
result = Response.GetString("UTF8")
Label_address.Text = "Postal address is " & result
End Sub

This is the basics from the code I use for reverse geocoding, hope it helps.
Latitude and longitude are numeric variables, result is a string variable and url is also a string variable.

Label_address.Text is a label that displays the location but you could easily change it for a string variable, eg
mylocation = result
which would store the address in a string variable called mylocation.

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
hey, thanks

the problem is that I use this, but I almost always have a bummer thing

XverhelstX

Sorry, was replying at the same time as you were and didn't see your second post.

I think you might have to figure out the script he uses (in Chrome you can inspect the page source and see how he calls the routines that do the work) and then send those as a http request and parse the result.

Dave
 
Upvote 0
Top