ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer
GeocodeFunctionality Class
Members  Example  See Also 
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




Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class GeocodeFunctionality 
   Implements IGeocodeFunctionalityIGISFunctionalityIOutputSpatialReference 
Visual Basic (Usage)Copy Code
Dim instance As GeocodeFunctionality
C# 
[SerializableAttribute()]
public class GeocodeFunctionality : IGeocodeFunctionalityIGISFunctionalityIOutputSpatialReference  

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).

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.GeocodeFunctionality

See Also

© 2010 All Rights Reserved.