B4J Question jgooglemaps addpolygon problem - maybe bug

bvonlaar

Member
Licensed User
Longtime User
Hello,
I want to display a collection of different polygons in jgooglemaps. So far I´m able to display a polygon. But when I load the second, third and fourth one, all polygons are connected with each other.

B4X:
Public Sub GPoly_Set1st

    Dim test As Int
    Dim row(12) As Object
    Dim rrow(11) As Object
    Dim tc As String
    Dim found As Boolean
    Dim event,MLabel As String
    Dim EVSel As Int
    Dim Flag As String
    found=False
    Main.TVP2.Items.Clear
    getCSVP
    Log(Main.fCounter)
    Main.TVLayer.SelectedRow=Main.RNoC-1 'sf.val(RNo)
    test=Main.RNoC-1
    Log(Main.rnoc)
    row=Main.TVLayer.SelectedRowValues
    Log(row(0))
    Main.RNo=row(0)
    Main.RNoC=Main.sf.Val(Main.RNo)
   
    If Main.MMap(Main.RNoC-1).IsInitialized=False Then
        Main.MMap(Main.RNoC-1).Initialize
    End If
    If Main.MMapCon.IsInitialized=False Then
        Main.MMapCon.Initialize
    End If
    If PolP.IsInitialized=False Then
        PolP.IsInitialized
    End If
    If PolL.IsInitialized=False Then
        PolL.Initialize
    End If
    If Main.MMarkMap(Main.RNoC-1).IsInitialized=False Then
        Main.MMarkMap(Main.RNoC-1).Initialize
    End If
    If Main.MMarkMapCon.IsInitialized=False Then
        Main.MMarkMapCon.Initialize
    End If   
   
    For i=0 To  ITCountP-1
        Main.TVP2.SelectedRow = i
        rrow=Main.TVP2.SelectedRowvalues
        Main.llat=rrow(1)
        Main.llong=rrow(2)
        PolP.Initialize(Main.sf.Val(Main.lLat),Main.sf.Val(Main.llong))

        event=Main.REvent
        If event="none" Then
            MLabel=" "
        Else
            Select event
                'Case "none"
                '        MLabel=""
                Case "Event1"
                    EVSel= 4
                Case "Event2"
                    EVSel= 5
                Case "Event3"
                    EVSel= 6
            End Select
            Main.TVLayer.SelectedRow=Main.RNoC-1 'sf.Val(RNo)
            row=Main.TVLayer.SelectedRowvalues
            MLabel=rrow(EVSel)
            rrow=Main.TVP2.SelectedRowvalues
           
        End If
          PolL.Add(PolP)
        Next
       
        'If Main.llat <> "" And Main.llong <> "" Then
        Dim MP As MapPolygon =Main.gmap.AddPolygon(PolL,2,fx.Colors.Yellow,fx.Colors.yellow,0.5)
            Main.MMap(Main.RNoC-1).Put(PolCount,MP)
            PolCount=PolCount+1
           
        'Dim MMarkLabel As MapPolygon = MP
''            If MLabel=" " Then
                'Dim M As Marker =gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp))
                'MMap.Put(i,M)
                'MMap.Put("MMark",gmap.AddMarker2(llat,llong,"",File.GetUri(File.DirAssets,RMarkTyp))) 'MMark)
''                Dim MP As MapPolygon =Main.gmap.AddPolygon(PolP, "",File.GetUri(File.DirAssets,RMarkTyp))
''                MMap(RNoC-1).Put(i,M)
                'MMapFl.Put(i,"True")
''            Else
                'Label2.Text=RMarkTyp
                'If t=1 Then
                'If MMap.ContainsKey(i) Then
                'Else
''                Dim M As Marker =gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp))
                'Dim MMarkLabel=
''                Dim MMarkLabel As Marker = M
                'SetMarkerLabel(gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp)),MLabel,RLColor,"18px")
''                SetMarkerLabel(M,MLabel,RLColor,"8px")
               
''                MMap(RNoC-1).Put(i,M)
                'Main.MMarkMap(Main.RNoC-1).Put(i,MMarkLabel)
''                'MMap(RNoC-1).Put(i,M)
''            End If
''            Label2.Text=RMarkTyp
        'End If
    'Next
   
    Main.RFlag="1"
    Main.TVLayer.SelectedRow=Main.RNoC-1
    row=Main.TVLayer.SelectedRowvalues

    row(11)=Main.RFlag
    Main.TVLayer.Items.Set(Main.RNoC-1,row)

    Main.MMapCon.Put(Main.RNoC-1,Main.MMap(Main.RNoC-1)) '(sf.Val(RNo),MMap)
    Main.MMarkMapCon.Put(Main.RNoC-1,Main.MMarkMap(Main.RNoC-1))
    '''    MMapCon.Put(RNoC-1,MMap(RNoC-1)) '(sf.Val(RNo),MMap)
    'MMapFl.Put(RNoC,RFlag) '(sf.Val(RNo),RFlag)
    'Log("reihe: " &RNo)
    'End If
    'Log(fCounter)
    'row=TVLayer.SelectedRowvalues
    Main.TVLayer.SelectedRowValues=row
    Main.TVLayer.Items.Set(Main.RNoC-1,row)
    Main.TVP2.Items.Clear
    'row(11)=RFlag
   
    'row(10)=MMap
    'TVLayer.Items.Set(row(10),MMap)
    Log("passpoint")
    't=2
End Sub

I can´t explain to myself where the mistake could be placed. It seems that the addpolyon routine isn´t closed up or a proccess isn´t completly finished.

The displayed data are from different csv-files.
Any idea?

Best
Benedikt
 

Attachments

  • Poly1.jpg
    Poly1.jpg
    77.9 KB · Views: 239
  • Poly2.jpg
    Poly2.jpg
    78.9 KB · Views: 237

bvonlaar

Member
Licensed User
Longtime User
Hello,
I want to display a collection of different polygons in jgooglemaps. So far I´m able to display a polygon. But when I load the second, third and fourth one, all polygons are connected with each other.

B4X:
Public Sub GPoly_Set1st

    Dim test As Int
    Dim row(12) As Object
    Dim rrow(11) As Object
    Dim tc As String
    Dim found As Boolean
    Dim event,MLabel As String
    Dim EVSel As Int
    Dim Flag As String
    found=False
    Main.TVP2.Items.Clear
    getCSVP
    Log(Main.fCounter)
    Main.TVLayer.SelectedRow=Main.RNoC-1 'sf.val(RNo)
    test=Main.RNoC-1
    Log(Main.rnoc)
    row=Main.TVLayer.SelectedRowValues
    Log(row(0))
    Main.RNo=row(0)
    Main.RNoC=Main.sf.Val(Main.RNo)
  
    If Main.MMap(Main.RNoC-1).IsInitialized=False Then
        Main.MMap(Main.RNoC-1).Initialize
    End If
    If Main.MMapCon.IsInitialized=False Then
        Main.MMapCon.Initialize
    End If
    If PolP.IsInitialized=False Then
        PolP.IsInitialized
    End If
    If PolL.IsInitialized=False Then
        PolL.Initialize
    End If
    If Main.MMarkMap(Main.RNoC-1).IsInitialized=False Then
        Main.MMarkMap(Main.RNoC-1).Initialize
    End If
    If Main.MMarkMapCon.IsInitialized=False Then
        Main.MMarkMapCon.Initialize
    End If  
  
    For i=0 To  ITCountP-1
        Main.TVP2.SelectedRow = i
        rrow=Main.TVP2.SelectedRowvalues
        Main.llat=rrow(1)
        Main.llong=rrow(2)
        PolP.Initialize(Main.sf.Val(Main.lLat),Main.sf.Val(Main.llong))

        event=Main.REvent
        If event="none" Then
            MLabel=" "
        Else
            Select event
                'Case "none"
                '        MLabel=""
                Case "Event1"
                    EVSel= 4
                Case "Event2"
                    EVSel= 5
                Case "Event3"
                    EVSel= 6
            End Select
            Main.TVLayer.SelectedRow=Main.RNoC-1 'sf.Val(RNo)
            row=Main.TVLayer.SelectedRowvalues
            MLabel=rrow(EVSel)
            rrow=Main.TVP2.SelectedRowvalues
          
        End If
          PolL.Add(PolP)
        Next
      
        'If Main.llat <> "" And Main.llong <> "" Then
        Dim MP As MapPolygon =Main.gmap.AddPolygon(PolL,2,fx.Colors.Yellow,fx.Colors.yellow,0.5)
            Main.MMap(Main.RNoC-1).Put(PolCount,MP)
            PolCount=PolCount+1
          
        'Dim MMarkLabel As MapPolygon = MP
''            If MLabel=" " Then
                'Dim M As Marker =gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp))
                'MMap.Put(i,M)
                'MMap.Put("MMark",gmap.AddMarker2(llat,llong,"",File.GetUri(File.DirAssets,RMarkTyp))) 'MMark)
''                Dim MP As MapPolygon =Main.gmap.AddPolygon(PolP, "",File.GetUri(File.DirAssets,RMarkTyp))
''                MMap(RNoC-1).Put(i,M)
                'MMapFl.Put(i,"True")
''            Else
                'Label2.Text=RMarkTyp
                'If t=1 Then
                'If MMap.ContainsKey(i) Then
                'Else
''                Dim M As Marker =gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp))
                'Dim MMarkLabel=
''                Dim MMarkLabel As Marker = M
                'SetMarkerLabel(gmap.AddMarker2(llat, llong, "",File.GetUri(File.DirAssets,RMarkTyp)),MLabel,RLColor,"18px")
''                SetMarkerLabel(M,MLabel,RLColor,"8px")
              
''                MMap(RNoC-1).Put(i,M)
                'Main.MMarkMap(Main.RNoC-1).Put(i,MMarkLabel)
''                'MMap(RNoC-1).Put(i,M)
''            End If
''            Label2.Text=RMarkTyp
        'End If
    'Next
  
    Main.RFlag="1"
    Main.TVLayer.SelectedRow=Main.RNoC-1
    row=Main.TVLayer.SelectedRowvalues

    row(11)=Main.RFlag
    Main.TVLayer.Items.Set(Main.RNoC-1,row)

    Main.MMapCon.Put(Main.RNoC-1,Main.MMap(Main.RNoC-1)) '(sf.Val(RNo),MMap)
    Main.MMarkMapCon.Put(Main.RNoC-1,Main.MMarkMap(Main.RNoC-1))
    '''    MMapCon.Put(RNoC-1,MMap(RNoC-1)) '(sf.Val(RNo),MMap)
    'MMapFl.Put(RNoC,RFlag) '(sf.Val(RNo),RFlag)
    'Log("reihe: " &RNo)
    'End If
    'Log(fCounter)
    'row=TVLayer.SelectedRowvalues
    Main.TVLayer.SelectedRowValues=row
    Main.TVLayer.Items.Set(Main.RNoC-1,row)
    Main.TVP2.Items.Clear
    'row(11)=RFlag
  
    'row(10)=MMap
    'TVLayer.Items.Set(row(10),MMap)
    Log("passpoint")
    't=2
End Sub

I can´t explain to myself where the mistake could be placed. It seems that the addpolyon routine isn´t closed up or a proccess isn´t completly finished.

The displayed data are from different csv-files.
Any idea?

Best
Benedikt

No bug, found error by myself.


B4X:
    If PolP.IsInitialized=False Then
        PolP.IsInitialized
    End If
    If PolL.IsInitialized=False Then
        PolL.Initialize
    Else
        PolL.Clear
    End If

Had to clear a list before filling with new data.

Benedikt
 
Upvote 0
Top