Simple code to display street address?

raytronixsystems

Active Member
Licensed User
Longtime User
Does anyone have any simple code to simply display the current street address using the GPS coordinates. I need number, street, zip code, state and/or country when a button is pressed by the user I have never worked with any of the GPS/Google Maps libraries and need a simple tutorial or sample code.

In the USA is there a call to display the current county?



thx,
Ray
 

mangojack

Well-Known Member
Licensed User
Longtime User
Same here

Error description: Missing parameter.
Occurred on line: 48
str = Geocoder.GetFromLocation(Location1.Latitude,Location1.Longitude,2)
Word: )
.. missing Tag parameter ??

Cheers mj
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Sorry, the application is using geocoder version 1, so you'll have to modify it to work with ver. 2.
Or better - take the example from the geocoder library files.

Edit: here are the corrected subs for ver 2 , taken from the original example and modified for my example:
B4X:
Sub GPS1_LocationChanged (Location1 As Location)
Geocoder.GetFromLocation(Location1.Latitude,Location1.Longitude,5,Null)
End Sub

Sub gec_GeocodeDone(Results() As Address, Tag As Object)
Dim place As String = ""
If Results.Length>0 Then
   For i=0 To Results.Length-1
      If Results(i).AddressLines.Size>0 Then
         For j = 0 To Results(i).AddressLines.Size - 1
            place = place & CRLF & Results(i).AddressLines.Get(j)
         Next
      End If
   Next
Else
   Msgbox("GetFromLocation", "No Address matched the Latitude and Longitude")
End If
   
addlbl.text = place 

End Sub
 
Last edited:
Upvote 0

raytronixsystems

Active Member
Licensed User
Longtime User
Thanks very much David!,

I corrected a few minor errors in your additions for version 2.0 of the library. They are:


B4X:
'
'need parameter for the initialize call in Activity_Create:
Geocoder.Initialize
' should be:
Geocoder.Initialize("Geocoder")

' spelling error:
'
Sub gec_GeocodeDone(Results() As Address, Tag As Object)
'
'should be:
Sub geocoder_GeocodeDone(Results() As Address, Tag As Object)

If I plug in my latitude and longitude to your geocoder library demo program i get all of the data i need such as address, citym, state and even the county.


Thanks,
Ray
 
Last edited:
Upvote 0
Top