Android Question parse data

jemel

Member
Licensed User
Longtime User
can someone help me for my problem on how to parse data, and use it in google map as latitude and longitude.
 

Attachments

  • Untitled1.png
    Untitled1.png
    146.6 KB · Views: 196
  • Untitled.png
    Untitled.png
    212.8 KB · Views: 121

sorex

Expert
Licensed User
Longtime User
something like (not tested tho)

B4X:
Dim lines() As String
Dim data() As String
lines=regex.split(chr(13)&chr(10),yourresponsetext)
for x=0 to lines.lenght-1
 data=regex.split(",",lines(x))
 if data.lenght>0 then  'check if it is a parameters line to skip the first line
  mylat=data(3)
  mylong=data(4)
  'do your other stuff here
 end if
next
 
Upvote 0

jemel

Member
Licensed User
Longtime User
something like (not tested tho)

B4X:
Dim lines() As String
Dim data() As String
lines=regex.split(chr(13)&chr(10),yourresponsetext)
for x=0 to lines.lenght-1
data=regex.split(",",lines(x))
if data.lenght>0 then  'check if it is a parameters line to skip the first line
  mylat=data(3)
  mylong=data(4)
  'do your other stuff here
end if
next

sorry newbie here, but it is not a textfile, it is a website. i need to get data from that website.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
yourresponsetext in my code is the text you get back from your webdownload (if it is in the same format otherwise the code is useless)
 
Upvote 0

jemel

Member
Licensed User
Longtime User
newbie here, this is my code i don't know how to get data and i dont know what library i should use
untitled1-png.31172


B4X:
#Region  Project Attributes
    #ApplicationLabel: Mapa
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
   
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
   
#End Region

Sub Process_Globals
End Sub

Sub Globals
   Dim mFragment As MapFragment
   Dim MapPanel As Panel
   Dim gmap1 As GoogleMap
   Dim gmapE As GoogleMapsExtras
    Dim line As Polyline
     Dim a As Int
     Dim mylat As String
Dim mylong As String
     a = 0
End Sub
Sub Activity_Create(FirstTime As Boolean)
   MapPanel.Initialize("")
   Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
   If mFragment.IsGooglePlayServicesAvailable = False Then
      ToastMessageShow("Google Play services not available.", True)
   Else
      mFragment.Initialize("Map", MapPanel)
   End If
  
   Dim Job1 As HttpJob
   Job1.Initialize("Job1", Me)
   Job1.Download("http://kidlat.pagasa.dost.gov.ph/cyclone.dat")
End Sub
Sub JobDone (Job As HttpJob)
   If Job.Success = True Then
   DownloadFiles(Job.GetString)
   End If
End Sub
Private Sub DownloadFiles (st As String)
mylat = Regex.Split(st,Chr(3))
mylong = Regex.Split(st,Chr(4))
End Sub
Sub Map_Ready
Log("MapFragment1_Ready")
    gmap1 = mFragment.GetMap
    gmap1.MyLocationEnabled=True
    gmap1.GetUiSettings.CompassEnabled=True
    Dim OnMyLocationButtonClickListener1 As OnMyLocationButtonClickListener
    OnMyLocationButtonClickListener1.Initialize("OnMyLocationButtonClickListener1")
    Dim OnMyLocationChangeListener1 As OnMyLocationChangeListener
    OnMyLocationChangeListener1.Initialize("OnMyLocationChangeListener1")
    gmapE.SetOnMyLocationChangeListener(gmap1, OnMyLocationChangeListener1)
     Dim List1 As List
     Dim Latlong1 As LatLng
     line = gmap1.AddPolyline
     line.Color=Colors.White
     line.Geodesic=True
     line.Visible =True
     line.Width=2
     List1.Initialize
     Latlong1.Initialize(25,120)
     List1.Add(Latlong1)
     Latlong1.Initialize(21,120)
     List1.Add(Latlong1)
     Latlong1.Initialize(15,115)
     List1.Add(Latlong1)
     Latlong1.Initialize(5,115)
     List1.Add(Latlong1)
     Latlong1.Initialize(5,135)
     List1.Add(Latlong1)
     Latlong1.Initialize(25,135)
     List1.Add(Latlong1)
     Latlong1.Initialize(25,120)
     List1.Add(Latlong1)
     line.Points=List1
     If a = 0 Then
     Dim CameraPosition1 As CameraPosition
     CameraPosition1.Initialize(13, 124, 4.3)
     gmap1.AnimateCamera(CameraPosition1)
     a = 1
     End If
Dim mylat1 As Double
Dim mylong1 As Double
mylat1 = mylat
mylong1 = mylong
gmap1.AddMarker(mylat1,mylong1, "")
End Sub
Sub OnMyLocationChangeListener1_MyLocationChange(location1 As Location )
   Log("Loc...changed...")
End Sub
Sub OnMyLocationButtonClickListener1_Click
Log("clicked")
End Sub
 
Upvote 0
Top