Android Question Assigning Lat/Lon from GPS

clooney48

Active Member
Licensed User
Longtime User
Hi!
Can anyone tell me why this code doesn´t work. I try only to assign the actual Lat Value to an existing DB-field (txtGPS). But there is nothing assigned in txtGPS.

B4X:
Sub BPosition_Click
Dim Location1 As Location
  ToastMessageShow("starte", True)
If GPS1.IsInitialized = False Then GPS1.Initialize("GPS")
    If GPS1.GPSEnabled = False Then
        ToastMessageShow("Please enable the GPS device.", True)
        StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
    Else
        GPS1.Start(0, 0) 'Listen to GPS with no filters.
        txtGPS.text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
    End If
End Sub
 

clooney48

Active Member
Licensed User
Longtime User
You need to add the GPS1_LocationChanged event !

B4X:
Sub GPS1_LocationChanged(Location1 as Location)
    txtGPS.text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
End Sub

Best regards.

Hi Klaus!

Thanks, but I tried this version before. It didn´t work too!

regards
clooney48
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
Could be! I did it inside after I checked the reception before and found two satellites. But perhaps the signals were too weak. I´ll try it outside. Thanks!
 
Upvote 0

吳界明

Member
Licensed User
Longtime User
Could I convert the LAT/LON to Real address, for example input 120.123,24.344 and return the real world address:Taiwan, Taichu, load, street.....
by use google map and how to mark it in MAP
 
Upvote 0

吳界明

Member
Licensed User
Longtime User
My codes write as follows, that is want to found the address, but the return list just contain the country & city Name
I need the full address expression which contained the street name and the number etc.
Please help me, thanks!

Sub geocoder_GeocodeDone(Results() As Address, Tag As Object)
Dim place As String = ""
Dim list1 As List

If Results.Length>0 Then
For i=0 To Results.Length-1
If Results(i).AddressLines.Size>0 Then
list1.initialize
list1.Add(Results(i).AddressLines)
For j = 0 To list1.Size-1
place = place & CRLF & list1.Get(j)
Next
End If
Next
Else
Msgbox("GetFromLocation", "No Address matched the Latitude and Longitude")
End If
Log(place)
addlbl.text = place

End Sub
 
Upvote 0
Top