iOS Question Google Maps get current position per code

Alexander Stolte

Expert
Licensed User
Longtime User
Hey,

I can not determine the current position. How does work in B4I?

My current code:

Code: Copy
Private Sub AddMap
    gmap.Initialize("gmap", Main.API_KEY_2)
    pnl_gmap.AddView(gmap, 0, 0, 100%X, 100%y)
    'gmap.MapType = gmap.MAP_TYPE_TERRAIN
    gmap.GetUiSettings.CompassEnabled = False
    gmap.GetUiSettings.MyLocationButtonEnabled = False
    gmap.MyLocationEnabled = True
  
    Msgbox(gmap.MyLocation.Latitude  & " und : " & gmap.MyLocation.Longitude ,"title")

End Sub

the output are "0"
 
You've just enabled the location tracking, don't expect it to be immediately available.

Code: Copy
Private Sub AddMap
    gmap.Initialize("gmap", Main.API_KEY_2)
    pnl_gmap.AddView(gmap, 0, 0, 100%X, 100%y)
    'gmap.MapType = gmap.MAP_TYPE_TERRAIN
    gmap.GetUiSettings.CompassEnabled = False
    gmap.GetUiSettings.MyLocationButtonEnabled = False
    gmap.MyLocationEnabled = True
    Do Until gmap.MyLocation.IsInitialized
    Sleep(1000)
    Loop
    Log(gmap.MyLocation.Latitude  & " und : " & gmap.MyLocation.Longitude)
    Msgbox(gmap.MyLocation.Latitude  & " und : " & gmap.MyLocation.Longitude ,"title")

End Sub
 
Upvote 0
Back
Top