iOS Question Latitude and Longitude of my Position

Discussion in 'iOS Questions' started by Marco Maria Vilucchi, Jul 20, 2015.

  1. Marco Maria Vilucchi

    Marco Maria Vilucchi Active Member Licensed User

    hi,
    i'm using googleMaps in my app and i need to konw my position: latitude and longitude.

    Here is my code:
    Code:
    gmap.Initialize("gmap", ApiKey)
        lisPNmap.AddView(gmap, 
    00100%X100%y)
        gmap.MapType = gmap.MAP_TYPE_TERRAIN
        gmap.GetUiSettings.CompassEnabled = 
    True
        gmap.GetUiSettings.MyLocationButtonEnabled = 
    True
        gmap.MyLocationEnabled = 
    True

        
    Dim mylat As Double
        
    Dim mylon As Double
     
        mylat=gmap.MyLocation.Latitude
        mylon=gmap.MyLocation.Longitude
        
    Log("MyLat: " & mylat)
        
    Log("MyLon: " & mylon)
    Log result is:

    MyLat: 0
    MyLon: 0

    but on google map the position is correct....(blue button near rome):
    upload_2015-7-20_14-4-43.png
    What should i do?
    thx
    Marco
     
    Last edited: Jul 20, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    This means that the location is not yet known at that point. Use a timer and check the location after a few seconds.
     
  3. Marco Maria Vilucchi

    Marco Maria Vilucchi Active Member Licensed User

    I Think location is known at that point: see blue bullet near rome. I'm here.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to understand it from this screenshot. If the location was known at that point it would have returned the correct values.
     
  5. Marco Maria Vilucchi

    Marco Maria Vilucchi Active Member Licensed User

    but MyLocationEnabled works...

    Code:
    gmap.Initialize("gmap", ApiKey)
        lisPNmap.AddView(gmap, 
    00100%X100%y)
        gmap.MapType = gmap.MAP_TYPE_TERRAIN
        gmap.GetUiSettings.CompassEnabled = 
    True
        gmap.GetUiSettings.MyLocationButtonEnabled = 
    True          <============= WORKS
        gmap.MyLocationEnabled = 
    True           <============= WORKS

        
    Dim mylat As Double
        
    Dim mylon As Double
        mylat=gmap.MyLocation.Latitude
        mylon=gmap.MyLocation.Longitude
        
    Log("MyLat: " & mylat)                       <============= DOESN'T WORK
        Log("MyLon: " & mylon)                      <============= DOESN'T WORK
    Why?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    All I can say that when the code is executed the location is not yet known.
     
Loading...