ThinkGeo.com    |     Blog    |     Wiki    |     Support

Lat/Lon from Address

Need to take and address and get the lat/lon. I think I’m almost there but keep getting an error at the GeoClt.Search line, “Sequence Contains No Elements”). Here’s the code:

Private Sub Btn_Geocode_Click(sender As Object, e As EventArgs) Handles Btn_Geocode.Click
    Dim GeoClt As New GeocodingClient("User","Secret")
    Dim GeoOpts As New GeocodingOptions()
    GeoOpts.SearchMode = GeocodingSearchMode.FuzzyMatch

    Dim result As GeocodingResult
    Dim resultLoc As GeocodingLocation
    result = GeoClt.Search(Txt_StreetAddress.Text & ", " & Txt_City.Text & ", " & Txt_State.Text & " " & Txt_Zipcode.Text, GeoOpts)
    resultLoc = result.Locations.First
    MsgBox(result.Locations(0).LocationPoint.X)

End Sub

Hi Steven,

I tried to test this API and it looks run without exception even I type in not existing address.

So could you please show us the search value: Txt_StreetAddress.Text & ", " & Txt_City.Text & ", " & Txt_State.Text & " " & Txt_Zipcode.Text

And we can test that in our side to reproduce this exception.

Please make sure you had upgrade all your packages to the latest version and let us know you are using release branch or development branch.

Regards,

Ethan

I meant to pull this post. I don’t know what was going on but it suddenly started to work. I can get the lat/lon’s fine now.

Again, thanks for putting up with me and my questions :slight_smile:

Hi Steven,

I am glad to hear it works there.

Any question please let us know.

Regards,

Ethan