I have the following code that receives fields from a MySQL database table:
I have this declared in "Globals":
I then attempt to get the Geocoder to obtain the street address information for each record received from MySQL table with:
In this Sub and try to add to Map "Transactions":
The problem I have is that
Private Sub Geocoder1_GeocodeDone(Results() As Address, Tag As Object)
is not called for each record.
It is only called after Sub getTransLastServer(fleet As String) is complete
B4X:
Sub getTransLastServer(fleet As String)
Dim msgid As String
Dim msgdeviceid As String
Dim msglat As String
Dim msglon As String
Dim msgvolts As String
Dim msgid As String
Dim msgsignal As String
Dim msgspeed As String = "000"
Dim msgdatetime As String
Dim msgfleet As String
Dim msgfriendname As String
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("get_trans_last", Array(fleet))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
For Each row() As Object In res.Rows
msgid = row(res.Columns.Get("id"))
msgdeviceid = row(res.Columns.Get("devicemac"))
msglat = row(res.Columns.Get("lat"))
msglon = row(res.Columns.Get("lon"))
msgvolts = row(res.Columns.Get("volts"))
msgsignal = row(res.Columns.Get("csq"))
' msgspeed = row(res.Columns.Get("speed"))
msgdatetime = row(res.Columns.Get("tstamp"))
msgfleet = row(res.Columns.Get("fleet"))
msgfriendname = row(res.Columns.Get("friendname"))
Log("***************************")
Log("msgid: " & msgid)
Log("msgdeviceid: " & msgdeviceid)
Log("msglat: " & msglat)
Log("msglon: " & msglon)
Log("msgvolts: " & msgvolts)
Log("msgsignal: " & msgsignal)
Log("msgspeed: " & msgspeed)
Log("msgdatetime: " & msgdatetime)
Log("msgfleet: " & msgfleet)
Log("msgfriendname: " & msgfriendname)
Log("***************************")
Transactions.Put(1, msgid)
Transactions.Put(2, msgdeviceid)
Transactions.Put(3, msglat)
Transactions.Put(4, msglon)
Transactions.Put(5, msgvolts)
Transactions.Put(6, msgid)
Transactions.Put(7, msgsignal)
Transactions.Put(8, msgspeed)
Transactions.Put(9, msgdatetime)
Transactions.Put(10, msgfleet)
Transactions.Put(11, msgfriendname)
addFN = msgfriendname
' Get the street Address
Geocoder1.GetFromLocation(Transactions.Get(3), Transactions.Get(4), 1, "1")
' Update table "trans"
insertTrans(msgid, msgdeviceid, msglat, msglon, msgvolts, msgid, msgsignal, msgspeed, msgdatetime, msgfleet, msgfriendname, myAdd1, myAdd2)
Next
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
I have this declared in "Globals":
B4X:
Dim Transactions As Map
Dim myAdd1 As String
Dim myAdd2 As String
I then attempt to get the Geocoder to obtain the street address information for each record received from MySQL table with:
B4X:
Geocoder1.GetFromLocation(Transactions.Get(3), Transactions.Get(4), 1, "1")
In this Sub and try to add to Map "Transactions":
B4X:
Private Sub Geocoder1_GeocodeDone(Results() As Address, Tag As Object)
myAdd1 = Results(0).SubThoroughfare & " " & Results(0).Thoroughfare
myAdd2 = Results(0).SubLocality & ", " & (Results(0).Locality) &", " & Results(0).AdminArea
Transactions.Put(12, myAdd1)
Transactions.Put(13, myAdd2)
Log("myAdd1: " & myAdd1)
Log("myAdd2: " & myAdd2)
End Sub
The problem I have is that
Private Sub Geocoder1_GeocodeDone(Results() As Address, Tag As Object)
is not called for each record.
It is only called after Sub getTransLastServer(fleet As String) is complete