Spanish [Solucionado] Problema al dibujar polilinea en OSM

Descartex

Well-Known Member
Licensed User
Muy buenas:
Estoy intentando dibujar una polilínea a partir de un archivo kml, del cual he conseguido sacar todos los puntos que la componen, parseandola con el SaxParser.
El codigo es este, pero no veo porque leches no dibuja ninguna linea, cuando la variable contorno tiene los puntos que le meto.
B4X:
Sub Globals
    Dim Archivo As SaxParser
    Dim MapView1 As MapView
    Dim contorno As PathOverlay
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If File.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")
    End If
   
    '    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.Initialize
    Dim fichero As InputStream
    fichero=File.OpenInput(File.DirAssets,"file.kml")
    Archivo.Parse(fichero,"Etiqueta")
End Sub

Sub Etiqueta_EndElement (Uri As String, Name As String, Text As StringBuilder)
    '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
                Dim point() As String
                point=Regex.Split(",",poly(i))
                Log(point.Length)
                x=point(0)
                y=point(1)
                Log("x="&x&" y="&y)
                contorno.AddPoint(x,y)
            Next
        End If
    End If

End Sub

Sub Activity_Resume
MapView1.AddOverlay(contorno)
End Sub

Un saludo por anticipado.
 

Descartex

Well-Known Member
Licensed User
Top