AnsweredAssumed Answered


Question asked by David.Kucharski@23 on Sep 12, 2018
Latest reply on Sep 14, 2018 by David.Kucharski@23

I have an ASP .net application referencing the ESRI.ArcGIS.ADF.Web.UI.WebControls to use a GeocodeResourceManager. I use this to pass addresses esri so I get back the latitude and longitude values. My overall question is what is the new way to perform this same process without the ESRI.ArcGIS.ADF.Web.UI.WebControls since I do not believe they are supported anymore.


<esri:GeocodeResourceManager ID="GeocodeResourceManager1" runat="server">
<esri:GeocodeResourceItem Definition="&lt;Definition DataSourceDefinition=&quot;" DataSourceType=&quot;ArcGIS Server Internet&quot; Identity=&quot;27ULNopWTKHTAvU3YGfdbamKkEqOGlhk5Ui6+keNMA1MXiQDDICNzA==&quot; ResourceDefinition=&quot;Geocode1&quot; /&gt;"
MinCandidateScore="80" MinMatchScore="80" Name="GeocodeResourceItem0" />


Within the code I have the following: 

' Get the resource item for the first item in the GeocodeResourceManager and make sure it's initialized
Dim geocodeResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.GeocodeResourceItem = GeocodeResourceManager1.ResourceItems(0)
If (Not geocodeResourceItem.Resource.Initialized) Then
End If

' Create a Web ADF Common API geocode functionality
Dim commonGeocodeFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality = CType(geocodeResourceItem.Resource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality)

Dim addressFieldList As System.Collections.Generic.List(Of ESRI.ArcGIS.ADF.Web.Geocode.Field) = commonGeocodeFunctionality.GetAddressFields()

Dim addressValueList As System.Collections.Generic.List(Of ESRI.ArcGIS.ADF.Web.Geocode.AddressValue) = New System.Collections.Generic.List(Of ESRI.ArcGIS.ADF.Web.Geocode.AddressValue)()

' Retrieve the input street from txtAddress and store in an AddressValue object
Dim streetAddressValue As ESRI.ArcGIS.ADF.Web.Geocode.AddressValue = New ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("STREET", tAddressStreet.Text.Trim() & "," & tAddressCity.Text.Trim() & "," & ddAddressState.SelectedValue.Trim())

' Retrieve the input zip from txtZipCode and store in an AddressValue object
Dim zoneAddressValue As ESRI.ArcGIS.ADF.Web.Geocode.AddressValue = New ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("Zip", tAddressZipCode.Text)

' Add the input street and zip to the list of address values

' Declare a Web ADF Point object to store the result geometry
Dim adfPoint As ESRI.ArcGIS.ADF.Web.Geometry.Point = Nothing

' Just get the one best-matching address
' Get the minimum match score from the minimum score drop-down
commonGeocodeFunctionality.MinMatchScore = Integer.Parse(80)

Dim matchDataTable As System.Data.DataTable
matchDataTable = commonGeocodeFunctionality.FindAddressCandidates(addressValueList, True, True)

'Find the index of the shape column from the results data table
Dim shapeColumnIndex As Integer = -1
For i As Integer = 0 To matchDataTable.Columns.Count Step 1
If matchDataTable.Columns(i).DataType Is GetType(ESRI.ArcGIS.ADF.Web.Geometry.Geometry) Then
shapeColumnIndex = i
Exit For
End If

For Each obj As System.Data.DataRow In matchDataTable.Rows
Dim adfPointAsObject As Object = obj(shapeColumnIndex)
If obj(1).ToString() = "Street_Address" Then
If TypeOf adfPointAsObject Is ESRI.ArcGIS.ADF.Web.Geometry.Point Then
adfPoint = CType(adfPointAsObject, ESRI.ArcGIS.ADF.Web.Geometry.Point)
Exit For
End If
End If

' Execute the geocode operation. In this case, we call GeocodeAddress, which returns
' only the best match as a Web ADF Point
'adfPoint = commonGeocodeFunctionality.GeocodeAddress(addressValueList)

' If a match was found, put it on the map
If (Not adfPoint Is Nothing) AndAlso ((Not adfPoint.X.Equals(Double.NaN))) Then
' Update the results and match count label controls. Use string.Format with N as the
' format provider to specify that the coordinates be presented in general numeric format.
Dim latitude() As String
latitude = adfPoint.Y.ToString().Split(".")
If Len(latitude(1)) > 6 Then
mlatitude = latitude(0) & "." & latitude(1).Substring(0, 6)
mlatitude = latitude(0) & "." & latitude(1)
End If

Dim longitude() As String
longitude = adfPoint.X.ToString().Split(".")
If Len(longitude(1)) > 6 Then
mlongitude = longitude(0) & "." & longitude(1).Substring(0, 6)
mlongitude = longitude(0) & "." & longitude(1)
End If
End If

' Check whether the match point is null or is populated with coordinates of NaN
If (Not adfPoint Is Nothing) AndAlso ((Not adfPoint.X.Equals(Double.NaN))) Then

' No results were found, so inform the user by setting the Label control
' accordingly
errorMessage = "No matching records can be found for this address. Please try again."
End If
Catch exception As System.Exception

End Try