Hi:
I'm trying to draw a polyline from a kml file, i've got all the points inside the file using SaxParser.
That's the code, but it doesn't draw anything and i don't see where is the mistake, var contorno has the points i've inserted.
Thanks a lot in advance.
I'm trying to draw a polyline from a kml file, i've got all the points inside the file using SaxParser.
That's the code, but it doesn't draw anything and i don't see where is the mistake, var contorno has the points i've inserted.
B4X:
Sub Globals
Dim Archivo AsSaxParser
Dim MapView1 As MapView
Dim contorno As PathOverlay
End Sub
Sub Activity_Create(FirstTime As Boolean)
IfFile.ExternalWritable=False Then
' OSMDroid requires the use of external storage to cache tiles' if no external storage is available then the MapView will display no tiles
Log("WARNING NO EXTERNAL STORAGE AVAILABLE")
EndIf ' no EventName is required as we don't need to listen for MapView events MapView1.Initialize("")
Activity.AddView(MapView1, 0, 0, 100%x, 100%y) ' by default the map will zoom in on a double tap and also be draggable - no other user interface features are enabled ' enable the built in zoom controller - the map can now be zoomed in and out
MapView1.SetZoomEnabled(True) ' enable the built in multi touch controller - the map can now be 'pinch zoomed'
MapView1.SetMultiTouchEnabled(True) ' set the zoom level BEFORE the center (otherwise unpredictable map center may be set)
MapView1.Zoom=8 MapView1.SetCenter(-11.7464,-75.7672)
contorno.Initialize(MapView1,Colors.Red)
Archivo.InitializeDim
fichero AsInputStream
fichero=File.OpenInput(File.DirAssets,"file.kml")
Archivo.Parse(fichero,"Etiqueta")
End Sub
Sub Etiqueta_EndElement (UriAsString, Name AsString, Text AsStringBuilder)
'Log(Name)
If Archivo.Parents.IndexOf("Document") > -1 Then
If Name = "coordinates" Then
Dim poly() As String
Log(Text.ToString)
poly=Regex.Split(" ",Text.ToString)
For i=0 To poly.Length-1
Dim x,y As Double
Dimpoint() AsString
point=Regex.Split(",",poly(i))
Log(point.Length)
x=point(0)
y=point(1)
Log("x="&x&" y="&y)
contorno.AddPoint(x,y)
Next
EndIf
EndIf
End Sub
Sub Activity_Resume
MapView1.AddOverlay(contorno)
End Sub
Thanks a lot in advance.