Android Question google map on different panels

tufanv

Expert
Licensed User
Longtime User
Hello

In my project i am initializing one googlemap object but i have 3 different panels controlled via tabhost. at first launch googlemap is added to panel1 via panel1.addview with a height of 30%y. Now, what i want to do is , add the initailized gmap object to panel2 and remove it from panel 1 with height of 90%y but without losing anything on it ( there is a route draw on gmap so when swtiching to panel 2 it must just move the gmap from panel1 to panel 2 with a new size )

I coldnt manage to do it. Can you help me

TY
 
You have to assign the mapfragment to a panel and then move the panel between the different panels in the tabhost, see this example:
Code: Copy
Sub Globals
   Dim mFragment As MapFragment
   Dim gmap As GoogleMap
   Dim GoogleMapsExtras1 As GoogleMapsExtras
 
   Dim MapPanel As Panel
   Dim panel1 As Panel
   Dim panel2 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

   MapPanel.Initialize("")
   panel1.Initialize("panel1")
   panel2.Initialize("panel2")
   Activity.AddView(panel1, 0, 0, 100%x, 70%y)
  
   Activity.AddView(panel2, 0, 70%y, 100%x, 30%y)

   panel1.AddView(MapPanel,0,0,100%x,100%y)
  
   If mFragment.IsGooglePlayServicesAvailable = False Then
      ToastMessageShow("Google Play services not available.", True)
   Else
      mFragment.Initialize("Map", MapPanel)
   End If
End Sub

Sub panel1_click
    MapPanel.RemoveView
    panel1.AddView(MapPanel,0,0,100%x,100%y)
End Sub
Sub panel2_click
    MapPanel.RemoveView
    panel2.AddView(MapPanel,0,0,100%x,100%y)
End Sub

Sub Map_Ready

   Log("map ready")
   gmap = mFragment.GetMap
   If gmap.IsInitialized = False Then
        ToastMessageShow("Error initializing map.", True)
   Else 
  
     gmap.MapType=gmap.MAP_TYPE_TERRAIN
     gmap.MyLocationEnabled = True
    
     'goto SW germany
     Dim cp As CameraPosition
     cp.Initialize(48.706214727530195,9.060724675655365, 7)
     gmap.AnimateCamera(cp)    
    
   End If
End Sub
 
Upvote 0
Back
Top