Android Question [Resolved]Google maps problem

magi6162

Well-Known Member
Licensed User
Table with 11 records
Field "Poligono" coord (lon/lat) of polygon
If I select a polygon at a time ok
if run under code i see on map only 3 polygon (0,10,6)
in attach database i use
in field "Poligono" data after ":" FillColor strokecolor strokewidth
Help me four days :(:(:(


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

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim mFragment As MapFragment
    Dim gmap As GoogleMap
    Dim MapPanel As Panel
    Dim gme As GoogleMapsExtras
    Dim wvMap As WebView
    Dim SAB As StdActionBar
     Dim BitmapDescriptor1 As BitmapDescriptor
    Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
    Dim mPoly As Map
    Dim pOptions As PolygonOptions
    Dim moEtichetta As MarkerOptions
    Dim mEtichetta As Map
    Dim PoligonoSelezionato As Polygon
    Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
    Dim c As Cursor
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("MappaGenerale")

    SAB.Initialize("SAB")
    SAB.Icon = LoadBitmap(File.DirAssets, "b_catalog_256.png")
    SAB.Subtitle = "Mappa generale"
    SAB.NavigationMode = SAB.NAVIGATION_MODE_STANDARD
    SAB.ShowUpIndicator = True

    wvMap.Width = 100%x + 7dip
    LatLngBoundsBuilder1.Initialize
    moEtichetta.Initialize
    moEtichetta.Draggable(False)
    mPoly.Initialize
    MapPanel.Initialize("")
    Definizione_PolyOptions

    LatLngBoundsBuilder1.Initialize
    c = Main.PMIT.ExecQuery("SELECT NTer," & _
                             "ifnull(CoordCentro,'') as CoordCentro," & _
                             "ifnull(Poligono,'') as Poligono," & _
                             "ifnull(Sospeso,'') as Sospeso," & _
                             "ifnull(Note,'') as Note, IDT " & _
                             "FROM Territori")
    Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
    If mFragment.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("I servizi di Google Play non sono disponibili.", True)
    Else
        mFragment.Initialize("Map", MapPanel)
    End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub SAB_ButtonClicked
    Activity.Finish
    StartActivity(Territori)
End Sub

'Sub Wait(MilliSekunden As Int)
'   Dim Ti As Long
'   Ti = DateTime.Now + MilliSekunden
'   Do While DateTime.Now < Ti
'      DoEvents
'   Loop
'End Sub

Sub Map_Ready
    gmap = mFragment.GetMap
    If gmap.IsInitialized = False Then
        ToastMessageShow("Errore inizializzando la mappa.", True)
    Else
        gmap.MapType = gmap.MAP_TYPE_HYBRID

        Dim cp As CameraPosition
        cp.Initialize(MITCode.SALA_Lat,MITCode.SALA_Lon,13)
        gmap.AnimateCamera(cp)
      
        Dim JavaObject1 As JavaObject
        JavaObject1=gmap.GetUiSettings
        JavaObject1.RunMethod("setMapToolbarEnabled", Array As Object(False))
      
        mEtichetta.Initialize
        Definizione_PolyOptions
              
        Log(c.RowCount)
        For i = 0 To c.RowCount - 1    -------- see only 0,10,6 position?????
            c.Position = i
            Log(i)
            Log(i & " " & c.GetString("Poligono"))
            If c.GetString("Poligono").CompareTo("") <> 0 Then
                Dim pList,cList,tList As List
                Dim sf As StringFunctions
                pList.Initialize
                cList.Initialize
                tList.Initialize
                sf.Initialize
                cList = sf.Split(c.GetString("Poligono"),":")
                Dim sp As String = cList.Get(0)
                sp = cList.Get(0)
                pList = sf.Split(sp,"-")
                Dim st As String = cList.Get(1)
                st = cList.Get(1)
                tList = sf.Split(st, " ")
                For i = 0 To pList.Size - 1
                    Dim pp As LatLng
                    Dim eP As String
                    eP = pList.Get(i)
                    pp.Initialize(eP.SubString(eP.IndexOf(" ") + 1),eP.SubString2(0,eP.IndexOf(" ")))
                    pOptions.AddPoint(pp)
                    LatLngBoundsBuilder1.Include(pp)
                Next
                Dim fc As Int = tList.Get(0)
                Dim sc As Int = tList.Get(1)
                Dim sw As Int = tList.Get(2)
                pOptions.FillColor = fc
                pOptions.StrokeColor = sc
                pOptions.StrokeWidth = sw              
                Dim poly As Polygon = gme.AddPolygon(gmap,pOptions)  
                mPoly.Put(c.getString("NTer"),poly)
                pOptions.Points.Clear
            End If  
            If c.GetString("CoordCentro") <> "" Then
                Dim pEtichetta As LatLng
                pEtichetta.Initialize(c.GetString("CoordCentro").SubString(c.GetString("CoordCentro").IndexOf(" ") + 1),c.GetString("CoordCentro").SubString2(0,c.GetString("CoordCentro").IndexOf(" ")))
                moEtichetta.Position(pEtichetta)
                 BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("number_" & c.GetString("NTer") & ".png")
'                 BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("grey_" & c.GetString("NTer") & ".png")
                 moEtichetta.Icon(BitmapDescriptor1)
                Dim EtichettaNTer As Marker = gme.AddMarker(gmap,moEtichetta)
                EtichettaNTer.Title = c.GetString("NTer")
                mEtichetta.Put(c.getString("NTer"),EtichettaNTer)
            End If
        Next
        c.Close
        Dim MarkerBounds As LatLngBounds = LatLngBoundsBuilder1.Build
        Dim cf As CameraUpdateFactory
        Dim cu As CameraUpdate
        cu = cf.NewLatLngBounds2(MarkerBounds,MapPanel.Width,MapPanel.Height,0)
        gme.AnimateCamera(gmap, cu)
    End If
End Sub

Sub Definizione_PolyOptions
    pOptions.Initialize
    pOptions.FillColor = Colors.ARGB(80,255,0,0)
    pOptions.StrokeColor = Colors.Black
    pOptions.StrokeWidth = 2
    pOptions.ZIndex = 3
    pOptions.Visible = True
End Sub
 

Attachments

Top