iOS Question googlemaps appears only small top of screen

JohnnyHamburg

Member
Licensed User
Longtime User
Hello,
i have a problem with googlemaps. On first start it only shows in top part of the screen like you can see from my screenshot.
When I go back to startpage and again to mappage, then it works fine.
I tryed a lot, but it seems to deal with the new Version B4i or Xcode, because it worked before.

 

Andris

Active Member
Licensed User
Longtime User

Do you have some lines of code that look something like this?
B4X:
    gmap.Initialize("gmap", API_Map)
    'add gmap into mfMap panel
    mfMap.AddView(gmap,0,0,mfMap.Width,mfMap.Height)

mfMap iwould be a panel in your layout that is placed at the size you want the map to be. At least this is the way I do it, and it works fine.
 
Upvote 0

JohnnyHamburg

Member
Licensed User
Longtime User
My code is this to add the map:

B4X:
Public Sub Show
    karte.Initialize("karte")
    karte.RootPanel.LoadLayout("tposmap")
    Main.NavControl.ShowPage(karte)
     AddMap
    Dim no As NativeObject
    Log("Version: " & no.Initialize("GMSServices").RunMethod("SDKVersion", Null).AsString)
End Sub

Private Sub AddMap
    gmap.Initialize("gmap", ApiKey)
    karte.RootPanel.AddView(gmap, 0, 0, 100%X, 100%y)
    gmap.MapType = gmap.MAP_TYPE_TERRAIN
    gmap.GetUiSettings.CompassEnabled = True
    gmap.GetUiSettings.MyLocationButtonEnabled = False
    gmap.MyLocationEnabled = True
'    gmap.GetUiSettings.ScrollGesturesEnabled = True
'    gmap.GetUiSettings.ZoomGesturesEnabled = True
    
    Pnlmember.Visible = False
    Btnmapchange.BringToFront
    Btnmembers.BringToFront
    BtnSchriftgros.BringToFront
    BtnSchriftklein.BringToFront
    Btnmyloc.BringToFront
    BtnZoommin.BringToFront
    BtnZoomplus.BringToFront

End Sub
 
Upvote 0

Andris

Active Member
Licensed User
Longtime User
I've found that using the 100%x and 100%y notation has led to problems in my code, when I use it as a parameter of a subroutine. There are some differences with B4A. Try this:
B4X:
Dim mwid,mhgt as int
mwid=100%x
mhgt=100%y
karte.RootPanel.AddView(gmap, 0, 0, mwid, mhgt)
See if that makes a difference.
 
Upvote 0

JohnnyHamburg

Member
Licensed User
Longtime User
Thank You, Andris. Your Code didn`t work either. But it gave me an idea. Now it works. I used the panel again and instead of 100%x, 100%y I put 320, 568.

B4X:
gmap.Initialize("gmap", ApiKey)
    PanelGMAP.AddView(gmap, 0, 0, 320, 568)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

JohnnyHamburg

Member
Licensed User
Longtime User



Sorry, Erel. That does not work. I tried. My code works fine. Hope it does also on Ipad and other devices. I use an Iphone 5s for testing.
 
Upvote 0

JohnnyHamburg

Member
Licensed User
Longtime User
Ok, I build a new project from my mainproject using only googlemaps relevant features. This works.
But I still cannot find the mistake. It happens only at the first start of googlemaps within a session and from the second time on everything is fine.
And It works using the workaround from my earlier post.

Sorry Erel, there is something wrong in my code, but I don`t find it since 4 days.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…