iOS Question Issue with Google Maps Camera Position in 1:1 Panel

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

I'm encountering an issue with Google Maps in my application. When I use Google Maps in full screen mode, the camera position works correctly. However, when I place the map inside a 1:1 aspect ratio panel, the camera position does not focus as expected.


Works well
B4X:
gmap.Initialize("gmap", ApiKey)
Root.AddView(gmap, 0,0,GetDeviceLayoutValues.Width,GetDeviceLayoutValues.Height)

Position is wrong
B4X:
gmap.Initialize("gmap", ApiKey)
pnl.AddView(gmap, 0, 0, pnl.Width,pnl.Width)


Despite setting the camera position , it doesn't focus correctly when the map is placed in the 1:1 panel. Any suggestions on how to resolve this issue would be greatly appreciated.

Thank you!
 

Attachments

  • sim1.jpg
    272 KB · Views: 25
  • Sim2.jpg
    261.2 KB · Views: 25

ykucuk

Well-Known Member
Licensed User
Longtime User
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The mistake is here:
B4X:
Private Sub Page_Resize (Width As Float, Height As Float)
    If gmap.IsInitialized Then gmap.SetLayoutAnimated(0, 1, 0, 0, Width, Height)
End Sub
You are resizing the map to the page size.

Best to handle the panel resize event instead:
B4X:
Private Sub Panel1_Resize (Width As Float, Height As Float)
    If gmap.IsInitialized Then gmap.SetLayoutAnimated(0, 1, 0, 0, Width, Height)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…