Provides methods and properties for geocoding (address matching) in the Web ADF through an ArcGIS Server service.
Object Model
Syntax
Visual Basic (Declaration) | |
---|
<SerializableAttribute()>
Public Class GeocodeFunctionality
Implements ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.IOutputSpatialReference |
C# | |
---|
[SerializableAttribute()]
public class GeocodeFunctionality : ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.IOutputSpatialReference |
Example
This example sets some locator properties, creates an AddressValue list, and then geocodes an address. The code assumes text boxes on the Page with the address values, a GeocodeResourceManager with a geocode resource added, and a label to display the result.
C# | Copy Code |
---|
ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeResource geoRes
= GeocodeResourceManager1.GetResource(0);
if (!geoRes.Initialized)
geoRes.Initialize();
ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality geoFunct =
(ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality)
geoRes.CreateFunctionality(
typeof(ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality), "geoFunct");
if (!geoFunct.Initialized)
geoFunct.Initialize();
Dictionary<string, object> locProps = geoFunct.GetLocatorProperties();
locProps["SideOffset"] = 10;
locProps["SideOffsetUnits"] = "Meters";
locProps["MinimumMatchScore"] = geoFunct.MinMatchScore;
List<ESRI.ArcGIS.ADF.Web.Geocode.AddressValue> addressVals =
new List<ESRI.ArcGIS.ADF.Web.Geocode.AddressValue>();
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue street =
new ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("Street", txtStreet.Text);
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue city =
new ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("City", txtCity.Text);
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue state =
new ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("State", txtState.Text);
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue zone =
new ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("Zip", txtZip.Text);
addressVals.Add(street);
addressVals.Add(city);
addressVals.Add(state);
addressVals.Add(zone);
ESRI.ArcGIS.ADF.Web.Geometry.Point geocodedPt =
geoFunct.GeocodeAddress(addressVals, locProps);
if (geocodedPt != null)
lblResult.Text = String.Format("Location found: x={0}, y={1}",
geocodedPt.X, geocodedPt.Y);
else
lblResult.Text = "No location found."; |
Visual Basic | Copy Code |
---|
Dim geoRes As ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeResource _
= GeocodeResourceManager1.GetResource(0)
If Not geoRes.Initialized Then
geoRes.Initialize()
End If
Dim geoFunct As ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality = _
CType(geoRes.CreateFunctionality( _
GetType(ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality), "geoFunct"), _
ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality)
If Not geoFunct.Initialized Then
geoFunct.Initialize()
End If
Dim locProps As Dictionary(Of String, Object) = geoFunct.GetLocatorProperties()
locProps("SideOffset") = 10
locProps("SideOffsetUnits") = "Meters"
locProps("MinimumMatchScore") = geoFunct.MinMatchScore
Dim addressVals As New _
List(Of ESRI.ArcGIS.ADF.Web.Geocode.AddressValue)()
Dim street As New _
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("Street", txtStreet.Text)
Dim city As New _
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("City", txtCity.Text)
Dim state As New _
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("State", txtState.Text)
Dim zone As New _
ESRI.ArcGIS.ADF.Web.Geocode.AddressValue("Zip", txtZip.Text)
addressVals.Add(street)
addressVals.Add(city)
addressVals.Add(state)
addressVals.Add(zone)
Dim geocodedPt As ESRI.ArcGIS.ADF.Web.GeomeTry.Point = _
geoFunct.GeocodeAddress(addressVals, locProps)
If geocodedPt IsNot Nothing Then
lblResult.Text = String.Format("Location found: x={0}, y={1}", _
geocodedPt.X, geocodedPt.Y)
Else
lblResult.Text = "No location found."
End If |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also