ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer
GeocodeFunctionality Class
Members  Example  See Also  Send Feedback
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer Namespace : GeocodeFunctionality Class




Provides methods and properties for geocoding (address matching) in the Web ADF through an ArcGIS Server service.

Object Model

GeocodeFunctionality Class

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 
Visual Basic (Usage)Copy Code
Dim instance As GeocodeFunctionality
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 BasicCopy 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

GeocodeFunctionality enables clients working with the Web ADF to perform geocoding, which typically involves obtaining an x,y location for an address. A GeocodeFunctionality is obtained through a geocode resource--for ArcGIS Server, specifically a GeocodeResourceInternet (for Internet/Web service connections) or GeocodeResourceLocal (for Local connections). The geocode resource's CreateFunctionality method may be used to obtain a GeocodeFunctionality object.

This GeocodeFunctionality class is the implementation of IGeocodeFunctionality for ArcGIS Server services. You can work at the generic interface level so that your code will also function with any Web ADF data source (ArcIMS, OGC WMS, etc.).

For a discussion of the geocoding functionality in the Web ADF, see the topic GeocodeResource in the Developer Help (also available online at the ArcGIS Resource Center).

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

© 2011 All Rights Reserved.