Android Question Add Google map to tab host

Indy

Active Member
Licensed User
Longtime User
Hi All,

I'm trying to add a panel that has a map on it to a tab host but, keep getting a "resource now found error" and it crashes out. I have used the Google Maps v2 example as my basis and by itself the example works fine. Problem with the example is it gets added to the activity which takes control of the entire screen, which is what I don't want. What I would like to do is have the map on one tab and other controls on other tabs so the user can flick in/out of the form before submitting the details.

I have tried to put the Maps panel inside another panel but then the map doesn't get initialised, which is what I think the error is.

Any help would be appreciated.

Thanks
 

Indy

Active Member
Licensed User
Longtime User
Without seeing your code it's impossible to a concrete advice.
You should post you project or a smaller onr that shows the problem.

Hi Klaus

Here's a excerpt from my project, which basically is built around the Google Maps v2 example.

B4X:
Sub Globals

   Dim mFragment As MapFragment
   Dim gmap As GoogleMap
   Dim MapPanel As Panel   

   Dim GoogleMapsExtras1 As GoogleMapsExtras
   
   Dim TB1 As TabHost
   
   Dim DummyPanel As Panel
   
   Dim TBMapPanel As Panel
   
   Dim L1 As Label

End Sub

Sub Activity_Create(FirstTime As Boolean)
   TB1.Initialize("Tab1")
   
   Activity.AddView(TB1, 0, 0, 100%x, 100%y)
   
   DummyPanel.Initialize("")
   MapPanel.Initialize("")   
   
   TBMapPanel.Initialize("")
   
   L1.Initialize("")
   L1.Text="Test"
   
   DummyPanel.AddView(L1,0,0,100,50)
   TBMapPanel.AddView(MapPanel, 0, 0, 100%x, 100%y)
   
   TB1.AddTab2("Form",DummyPanel)
   
   'Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
   
   TB1.AddTab2("Map",TBMapPanel)

   If mFragment.IsGooglePlayServicesAvailable = False Then
     ToastMessageShow("Google Play services not available.", True)
   Else
     mFragment.Initialize("Map", MapPanel)     
   End If  
 
End Sub

As I mentioned in my OP, the maps work absolutely fine if you assign it to the activity, of course that means you can't see any other control. If you plug the above (plus all the other configuration you have to do to get the API key) into the Google maps example code you'll basically have what I have.

Thanks for your help.
 
Upvote 0
Top