Android Question MapFragment1 Inside a panel without using visual desinger

victormedranop

Well-Known Member
Licensed User
Longtime User
i 'm stuck with this
this is par of may code

B4X:
Dim news As Panel
    news.Initialize("news")
    Dim bgnews As ColorDrawable
    bgnews.Initialize(Colors.Yellow,20)
    news.Background = bgnews
    Root.AddView(news,5%x, 13%y,90%x, 20%y)
    
    Dim maps As Panel
    maps.Initialize("maps")
    
    MapFragment1.Initialize("MapFragment1",maps)
    
    maps.AddView(MapFragment1,0%x,0%y,100%x,100%y)
    
    Dim bgmap As ColorDrawable
    bgmap.Initialize(Colors.blue,20)
    maps.Background = bgmap
    
    Root.AddView(maps,5%x, 35%y,90%x, 65%y)
    
    Wait For MapFragment1_Ready
    gmap = MapFragment1.GetMap
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        gmap.MyLocationEnabled = True
    Else
        Log("No permission!")
    End If

i kept getting the same error.

maps.AddView(MapFragment1,0%x,0%y,100%x,100%y)
src\b4a\example\login.java:295: error: incompatible types: MapFragmentWrapper cannot be converted to View
 

victormedranop

Well-Known Member
Licensed User
Longtime User
Find my answer, lets try. if some one can help with some code will be appreciated.

this the answer

 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
More simple than expected
ad new layout with mapfragment and add to a panel.

B4X:
Dim news As Panel
    news.Initialize("news")
    Dim bgnews As ColorDrawable
    bgnews.Initialize(Colors.Yellow,20)
    news.Background = bgnews
    Root.AddView(news,5%x, 13%y,90%x, 20%y)
    
'    Dim maps As Panel
'    maps.Initialize("maps")
    
    
    
    Dim maps As Panel = xui.CreatePanel("maps")
    maps.LoadLayout("MapsPage")
    
    
'    Dim bgmap As ColorDrawable
'    bgmap.Initialize(Colors.blue,20)
'    maps.Background = bgmap
    
    Root.AddView(maps,5%x, 35%y,90%x, 65%y)
 
Upvote 0
Top