Android Question Loading correctly Place Autocomplete

enrfortin

Member
Licensed User
i read this thread https://www.b4x.com/android/forum/threads/b4x-custom-view-google-place-autocomplete-view.81976/
and works but not as I expected i want a search like a postman this the request i send.

and i get this result:

1674104302711.png




in the app i dont get results.

1674104430146.png


this is the code i sue for the edittext change event:

et_TextChanged:
Private Sub et_TextChanged (Old As String, New As String)

    If New.Length = 0 Then

        lv.Clear

        lv.Visible = False

    Else

        If lv.Visible = False Then lv.Visible = True

        Dim j As HttpJob

        j.Initialize("", Me)

        j.Download2("https://maps.googleapis.com/maps/api/place/autocomplete/json", _

            Array As String("input", New & " Tegucigalpa&types=establishment", "key", GlobalParameters.GoogleApiKey))

        QueryIndexSent = QueryIndexSent + 1

        Dim index As Int = QueryIndexSent

        Wait For (j) JobDone (j As HttpJob)

      

        If j.Success Then

            If QueryIndexReceived > index Then

                Return

            Else

                Dim pds As List

                pds.Initialize

                lv.Clear

                QueryIndexReceived = index

                Dim jp As JSONParser

                jp.Initialize(j.GetString)

                Dim m As Map = jp.NextObject

                Dim predictions As List = m.Get("predictions")

                For Each pred As Map In predictions

                    Dim pd As PlaceData

                    pd.Initialize

                    pd.Id = pred.Get("place_id")

                    pd.Description = pred.Get("description")

                    pds.Add(pd)

                Next

                AddItemsToList(pds, New.ToLowerCase)

            End If

        End If

        j.Release

    End If

End Sub

i really dont know what is the problem.

thanking you in advance for all the support that this great community has given me.
 

Attachments

  • B4A Samples.zip
    247.5 KB · Views: 62
Last edited:
Top