Android Question Gps library

Isac

Active Member
Licensed User
Longtime User
Hello,
how can I get the address of a street?
with the library gps I have not found anything useful
thank you
 

Peter Simpson

Expert
Licensed User
Longtime User
Get the GPS location, then try using an online service to get the road name information that you're looking for. I presume that there's a service that will do that for you.

You can do it the other way around easily enough by using Geocoding. Maybe there's an API that will give you exactly what you are looking for.
https://developers.google.com/maps/documentation/geocoding/?csw=1#Geocoding
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Geocoder library !
B4X:
        Geocoder.GetFromLocation(point.Lat,point.Lon,2, Null)
...
End Sub

Sub Geocoder_GeocodeDone(Results() As Address, Tag As Object)
    If Results.Length>0 Then
        Dim Address1 As Address
        Address1=Results(0)
        If Address1.AddressLines.Size>0 Then
            For j = 0 To Address1.AddressLines.Size-1
                place = place & " " & Address1.AddressLines.Get(j) & " "
            Next
        End If
    End If
    display_parameter = place
End Sub
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Geocoder library !
B4X:
        Geocoder.GetFromLocation(point.Lat,point.Lon,2, Null)
...
End Sub

Sub Geocoder_GeocodeDone(Results() As Address, Tag As Object)
    If Results.Length>0 Then
        Dim Address1 As Address
        Address1=Results(0)
        If Address1.AddressLines.Size>0 Then
            For j = 0 To Address1.AddressLines.Size-1
                place = place & " " & Address1.AddressLines.Get(j) & " "
            Next
        End If
    End If
    display_parameter = place
End Sub

My GPS (Garmin Nuvi) got stolen from my car last Summer... :(

Now, seeing how easy to use this lib looks, I'm starting to consider creating my own GPS app! :D

Derez, is there any chance that your path finding algorithms can work together with real world maps (such as Google Maps)?

58340911.jpg
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
with real world maps (such as Google Maps)
i guess NO. Google Maps, and also other map solutions, presents you images... Depending on the zoomlevel they are more clear and detailed (showing streetnames). But they are just images. Google does not expose Streetnames in the api.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
The address details in geocoder are coming from google and they need network for getting the data.
The map is another issue.
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
Thank you all for your attention
but I honestly do not understand how to use the library Geocoder.
I simply need to obtain the address and read it into a label.

Library gps I always use it to get lat and long right?

B4X:
Sub GPS_LocationChanged (Location1 As Location)  
    lon1 =Location1.Latitude
    long2 =Location1.Longitude
    Label1.Text="Latitude: "&lon1
    Label2.Text="Longitude: "&long2
    Label4.Text=geo.GetFromLocation(long2,lon1,2,Null)
End Sub

Thank You
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You need to get the value in the sub
B4X:
Sub Geocoder_GeocodeDone(Results() As Address, Tag As Object)
    If Results.Length>0 Then
        Dim Address1 As Address
        Address1=Results(0)
        If Address1.AddressLines.Size>0 Then
            For j = 0 To Address1.AddressLines.Size-1
                place = place & " " & Address1.AddressLines.Get(j) & " "
            Next
        End If
    End If
End Sub
and then put it onto your label(s)
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
I see nothing in the label, but it is correct to put a NULL?


B4X:
Sub GPS_LocationChanged (Location1 As Location)   
   
    lon1 =Location1.Latitude
    long2 =Location1.Longitude
    Label1.Text="Latitude: "&lon1
    Label2.Text="Longitude: "&long2
    geo.GetFromLocation(long2,lon1,2,Null)

End Sub

Sub Geocoder_GeocodeDone(Results() As Address, Tag As Object)
   
    If Results.Length>0 Then
        Dim Address1 As Address
        Address1=Results(0)
        If Address1.AddressLines.Size>0 Then
            For j = 0 To Address1.AddressLines.Size-1
                place = place & " " & Address1.AddressLines.Get(j) & " "
            Next
        End If
    End If
    Label4.Text = place
End Sub
 
Upvote 0
Top