Android Question Google Geocoding Problem (Geocoder library)

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
With Geocoder library, I can't get "Sub LatLonToPlace (lat As Double, lon As Double)" to run
It seems that the part of the code( between green lines x) is not considered
B4X:
Sub LatLonToPlace(lat As Double, lon As Double) 'As ResumableSub
    
    Dim API_KEY As String = "AIzaSyDoxxxxxxxxxxxxxrvu5oPI"
    Dim res As String
    Dim GetAddressJob As HttpJob
    GetAddressJob.Initialize("GetAddress", Me)
    GetAddressJob.Download2("https://maps.googleapis.com/maps/api/geocode/json", Array As String("latlng", lat & "," & lon,"key",API_KEY))
    Wait For (GetAddressJob) JobDone(GetAddressJob As HttpJob)
    If GetAddressJob.Success Then
        Dim jp As JSONParser
        jp.Initialize(GetAddressJob.GetString)
        Dim m As Map = jp.NextObject
        
        'xxxxxxxxxxxxxx No runs beneath xxxxxxxxxxxxxxxxx
        If m.Get("status") = "OK" Then
            Dim results As List = m.Get("results")
            If results.Size > 0 Then
                Dim first As Map = results.Get(0)
                res = first.Get("formatted_address")
                Log(res)
                'res contain address string
            End If
        End If
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   
        
    End If
    GetAddressJob.Release
End Sub
Which libraries are needed ?
Have I forgotten something?
Thank you
 

AnandGupta

Expert
Licensed User
Longtime User

Attachments

  • Screenshot_2020-10-03-21-07-54-713_com.android.chrome.jpg
    Screenshot_2020-10-03-21-07-54-713_com.android.chrome.jpg
    250.9 KB · Views: 184
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Glad to help :)

Like the threads which helped you, if you are happy.
And also mark this thread as [Solved]

Regards

Anand
 
Last edited:
Upvote 0

magdoz

Member
Licensed User
Thanks friends. I have one application what will collect gps and environmental data from several devices placed around of nz. I used Bananovuetify for frontend app. Everything working smoothly, just needed some gmap api using examples and how to use... i got from this thread... Thank again.
 
Upvote 0
Top