AnsweredAssumed Answered

VB.NET Display multiple Geosearch results

Question asked by cdebruin on Jan 8, 2013
Latest reply on Jan 9, 2013 by cdebruin
I've written a GeocodeAddress method which is a modified version of the SDK FindAddress sample. I'm using a local address locator and I can't understand how to make it return multiple results. It is only returning the first result.

If I use the same locator in ArcMap's native Find tool, it pulls up a bunch of records.

All help is appreciated,
Corbin de Bruin

 Private Sub GeocodeAddress()         locatorManager = TryCast(obj, ILocatorManager2)         locatorWorkspace = locatorManager.GetLocatorWorkspaceFromPath(gLocatorWorkspace)          Dim locator As ILocator = locatorWorkspace.GetLocator("Street_Addresses_US")          ' Set up the address properties         Dim addressInputs As IAddressInputs = TryCast(locator, IAddressInputs)         Dim addressFields As IFields = addressInputs.AddressFields         Dim addressProperties As IPropertySet = New PropertySetClass()         addressProperties.SetProperty(addressFields.Field(0).Name, txtAddress.Text)         addressProperties.SetProperty(addressFields.Field(1).Name, txtCity.Text)         addressProperties.SetProperty(addressFields.Field(2).Name, txtState.Text)         addressProperties.SetProperty(addressFields.Field(3).Name, txtZIP.Text)          ' Match the Address         Dim addressGeocoding As IAddressGeocoding = TryCast(locator, IAddressGeocoding)         Dim resultSet As IPropertySet = addressGeocoding.MatchAddress(addressProperties)          'Write results to DataGridView         Dim names, values As Object ' Not sure how these ever really get populated. They produce a warning where a null reference exception could be produced         resultSet.GetAllProperties(names, values)         Dim namesArray() As String = TryCast(names, String())         Dim valuesArray() As Object = TryCast(values, Object())         Dim length As Integer = namesArray.Length ' Not terribly sure what this line does.         Dim addressPoint As IPoint = Nothing         dgvAddrResults.Rows.Add() ' Create DataGridRow to hold result         For i As Integer = 0 To length - 1             Select Case namesArray(i) ' Case Statement to write proper fields to DataGrid Columns                 Case "Status"                     If valuesArray(i).ToString() = "U" Then                         lblAddressPrompt.Text = "***Address was not found."                         lblAddressPrompt.Visible = True                         Exit Sub                     End If                 Case "Shape"                     addressPoint = TryCast(valuesArray(i), IPoint)                     If addressPoint IsNot Nothing AndAlso (Not addressPoint.IsEmpty) Then                         dgvAddrResults.Item("Coordinates", 0).Value = addressPoint.X.ToString & ", " & addressPoint.Y.ToString                     Else                         dgvAddrResults.Item("Coordinates", 0).Value = "No geographic point available"                     End If                 Case "Score"                     dgvAddrResults.Item("Score", 0).Value = valuesArray(i).ToString()                 Case "Match_addr"                     dgvAddrResults.Item("Address", 0).Value = valuesArray(i).ToString()                 Case "Addr_type"                     dgvAddrResults.Item("Type", 0).Value = valuesArray(i).ToString()             End Select          Next i      End Sub