Marco Maria Vilucchi Active Member Licensed User Longtime User Jul 20, 2015 #1 hi, i'm using googleMaps in my app and i need to konw my position: latitude and longitude. Here is my code: B4X: gmap.Initialize("gmap", ApiKey) lisPNmap.AddView(gmap, 0, 0, 100%X, 100%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): What should i do? thx Marco Last edited: Jul 20, 2015
hi, i'm using googleMaps in my app and i need to konw my position: latitude and longitude. Here is my code: B4X: gmap.Initialize("gmap", ApiKey) lisPNmap.AddView(gmap, 0, 0, 100%X, 100%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): What should i do? thx Marco
Erel B4X founder Staff member Licensed User Longtime User Jul 21, 2015 #2 This means that the location is not yet known at that point. Use a timer and check the location after a few seconds. Upvote 0
This means that the location is not yet known at that point. Use a timer and check the location after a few seconds.
Marco Maria Vilucchi Active Member Licensed User Longtime User Jul 23, 2015 #3 I Think location is known at that point: see blue bullet near rome. I'm here. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jul 23, 2015 #4 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. Upvote 0
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.
Marco Maria Vilucchi Active Member Licensed User Longtime User Jul 23, 2015 #5 but MyLocationEnabled works... B4X: gmap.Initialize("gmap", ApiKey) lisPNmap.AddView(gmap, 0, 0, 100%X, 100%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? Upvote 0
but MyLocationEnabled works... B4X: gmap.Initialize("gmap", ApiKey) lisPNmap.AddView(gmap, 0, 0, 100%X, 100%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?
Erel B4X founder Staff member Licensed User Longtime User Jul 24, 2015 #6 All I can say that when the code is executed the location is not yet known. Upvote 0