iOS Question Google Maps get current position per code

Discussion in 'iOS Questions' started by Alexander Stolte, Apr 16, 2018.

  1. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Hey,

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

    My current code:

    Code:
    Private Sub AddMap
        gmap.Initialize(
    "gmap", Main.API_KEY_2)
        pnl_gmap.AddView(gmap, 
    00100%X100%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"
     
  2. Erel

    Erel Administrator Staff Member Licensed User

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

    Code:
    Private Sub AddMap
        gmap.Initialize(
    "gmap", Main.API_KEY_2)
        pnl_gmap.AddView(gmap, 
    00100%X100%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
     
    Alexander Stolte likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice