Android Question Map is not ready yet.

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

I Created Layout file only with MapFragment view (Custom view)

I have panel and i load layout file that i created.

i got error when try to add marker "Maps is not ready yet" but i have map in panel and it works as normal


B4X:
Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
Dim m1 As Marker = gmap.AddMarker(10, 30, "test") ' error line
m1.Snippet = "This is the snippet"
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Globals
   Private gmap As GoogleMap
   Private MapFragment1 As MapFragment
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Activity.LoadLayout("1") ' Not loading layout here
   Dim p As Panel
     p.Initialize("Panel")
     Activity.AddView(p,0,0,100%x,100%y)
     p.LoadLayout("1") ' load the layout with the mapfragment
     If MapFragment1.IsGooglePlayServicesAvailable = False Then
     ToastMessageShow("Please install Google Play Services.", True)
   End If
End Sub

Sub MapFragment1_Ready
   Log("MapFragment1_Ready")
     gmap = MapFragment1.GetMap
   Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
   m1.Snippet = "This is the snippet"
   
   
End Sub

Works for me (please note the needed changes in manifest)
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello, I got error with your code also. Could you check picture please.

This activity is not main activity. Google map is running if i don't add marker.

Google Map Library v2
B4A IDE v6.0
 

Attachments

  • Screen Shot 2016-08-30 at 22.14.15.png
    Screen Shot 2016-08-30 at 22.14.15.png
    97.2 KB · Views: 174
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
when i delete below code it works well.
B4X:
SetTheme(res.GetResourceId("style", "android:style/Theme.Holo.Light.DarkActionBar"))

This is the function

B4X:
Private Sub SetTheme (Theme As Int)

    If Theme = 0 Then

        ToastMessageShow("Theme not available.", False)

        Return

    EndIf

    If Theme = Theme_Value Then Return

    Theme_Value = Theme

    Activity.Finish

    StartActivity(Me)               

EndSub

#if java

public void _onCreate() {

    if (_theme_value != 0)

        setTheme(_theme_value);

}

#end if
 
Upvote 0
Top