Android Question Get country, city, street name based on latitude and longitude

rzv25

Member
Licensed User
Longtime User
Hello all,

Seems that my question was asked like 6 years ago here and I see in the end that the recommendation is to start a new thread.
So, 6 years later, is there any simpler way to get the country, city and street name based on the latitude and longitude returned from GPS library ?

Thank you
 

KMatle

Expert
Licensed User
Longtime User
Another way:

B4X:
ub GetAddress (lat As Float, lon As Float)
    Dim GetAddressJob As HttpJob
    GetAddressJob.Initialize("GetAddress", Me)
    GetAddressJob.Download2("https://maps.googleapis.com/maps/api/geocode/json", _
              Array As String("latlng", lat & "," & lon))
   
End Sub

It calls Google's geocode function. You get a whole bunch of info's back (full address, etc.) just by providing lat & lon. Very cool and powerful!
 
Upvote 0

rzv25

Member
Licensed User
Longtime User
You should have a look at the Geocoder library.
Thank you for the hint, klaus. I've looked a bit on the thread and saw that some people complaint that at some point in time it has stopped working.

Another way:

B4X:
ub GetAddress (lat As Float, lon As Float)
    Dim GetAddressJob As HttpJob
    GetAddressJob.Initialize("GetAddress", Me)
    GetAddressJob.Download2("https://maps.googleapis.com/maps/api/geocode/json", _
              Array As String("latlng", lat & "," & lon))
  
End Sub

It calls Google's geocode function. You get a whole bunch of info's back (full address, etc.) just by providing lat & lon. Very cool and powerful!

Thank you very much KMatle, I was just about to put a question about this as I saw this post while looking in the Geocoder library thread. Have any idea if there is a simple way to parse the returned info and extract the needed fields ?
 
Upvote 0
Top