This document is archived and information here might be outdated.  Recommended version.


LocationUI (ArcObjects .NET 10.5 SDK)

LocationUI


Supported with:
  • ArcGIS for Desktop Basic
  • ArcGIS for Desktop Standard
  • ArcGIS for Desktop Advanced
Library dependencies: Version, System, SystemUI, Geometry, GraphicsCore, Display, Server, Output, Geodatabase, GISClient, DataSourcesFile, DataSourcesGDB, DataSourcesOleDB, DataSourcesRaster, DataSourcesNetCDF, GeoDatabaseDistributed, GeoDatabaseExtensions, Carto, NetworkAnalysis, Location, GeoAnalyst, Animation, Maplex, Geoprocessing, NetworkAnalyst, Schematic, SpatialAnalyst, 3DAnalyst, GlobeCore, EngineCore, TrackingAnalyst, Framework, Desktop.Addins, GeoDatabaseUI, DisplayUI, OutputUI, Search, Catalog, CatalogUI, CartoUI, DataSourcesRasterUI, ArcCatalog, ArcCatalogUI, ArcMap, ArcMapUI, AnimationUI, Editor, GeoReferenceUI, EditorExt

Additional library information: Contents, Object Model Diagram

To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
The LocationUI library provides user interface objects to support objects contained in the Location library. The LocationUI library also contains objects that extend other core libraries of the ArcGIS system, such as Catalog, CatalogUI, and CartoUI.

See the following sections for more information about this namespace:

Locator user interfaces

The locator user interface (UI) objects provide UIs for locators in ArcGIS.
A LocatorUI object provides the basic UI functionality for working with a locator in ArcGIS. It opens the UI for creating a locator, modifying the properties of a locator, and geocoding a table of addresses. An ESRILocatorUI object provides additional UIs to expose all the functionality of address locators that use the ESRI geocoding engine. There are two types of ESRILocatorUI objects: AddressLocatorUI objects that provide UIs for ESRIAddressLocator objects and CompositeLocatorUI objects that provide UIs for composite address locators.
The following code example illustrates how to use the AddressLocatorUI associated with a locator to open the UI for geocoding one set of tables in an ArcMap document:
[VB.NET]
Public Sub GeocodeUsingAddressLocatorUI()
    
    ' Get a reference to the LocatorExtension.
    Dim locatorExtensionUID As UID=New UIDClass
    locatorExtensionUID.Value="esriLocationUI.LocatorExtension"
    Dim application As IApplication=New AppRefClass
    Dim extension As IExtension=application.FindExtensionByCLSID(locatorExtensionUID)
    Dim locatorExtension As ILocatorExtension=TryCast(extension, ILocatorExtension)
    
    ' Get the current AddressLocator from the LocatorExtension.
    Dim currentLocator As Int32=locatorExtension.CurrentLocator("Address")
    Dim locator As ILocator=locatorExtension.Locator("Address", currentLocator)
    
    ' Get the set of tables from the current ArcMap document.
    Dim document As IDocument=application.Document
    Dim mxDocument As IMxDocument=TryCast(document, IMxDocument)
    Dim map As IMap=mxDocument.FocusMap
    Dim tableCollection As ITableCollection=TryCast(map, ITableCollection)
    Dim tableSet As ISet=New SetClass
    
    Dim table As ITable=Nothing
    Dim tableIndex As Int32
    For tableIndex=0 To tableCollection.TableCount - 1
        If tableIndex=0 Then
            table=tableCollection.Table(tableIndex)
        End If
        tableSet.Add(tableCollection.Table(tableIndex))
    Next tableIndex
    
    ' Get the user interface for the AddressLocator, and open a dialog to geocode from the set of
    ' tables in the ArcMap document.
    Dim locatorUI As ILocatorUI=locator.UserInterface
    Dim addressUI As IAddressUI=TryCast(locatorUI, IAddressUI)
    Dim parentWindow As Int32=application.hWnd
    Dim Name As IName=addressUI.MatchTableFromSet(parentWindow, tableSet, table, True, locator, "")
    
End Sub
[C#]
public void GeocodeUsingAddressLocatorUI()
{
    // Get a reference to the LocatorExtension.
    UID locatorExtensionUID=new UIDClass();
    locatorExtensionUID.Value="esriLocationUI.LocatorExtension";
    IApplication application=new AppRefClass();
    IExtension extension=application.FindExtensionByCLSID(locatorExtensionUID);
    ILocatorExtension locatorExtension=extension as ILocatorExtension;

    // Get the current AddressLocator from the LocatorExtension.
    Int32 currentLocator=locatorExtension.get_CurrentLocator("Address");
    ILocator locator=locatorExtension.get_Locator("Address", currentLocator);

    // Get the set of tables from the current ArcMap document.
    IDocument document=application.Document;
    IMxDocument mxDocument=document as IMxDocument;
    IMap map=mxDocument.FocusMap;
    ITableCollection tableCollection=map as ITableCollection;
    ISet tableSet=new SetClass();

    ITable table=null;
    Int32 tableIndex=0;
    for (tableIndex=0; tableIndex < tableCollection.TableCount; tableIndex++)
    {
        if (tableIndex == 0)
        {
            table=tableCollection.get_Table(tableIndex);
        }
        tableSet.Add(tableCollection.get_Table(tableIndex));
    }

    // Get the user interface for the AddressLocator, and open a dialog to geocode from the set of
    // tables in the ArcMap document.
    ILocatorUI locatorUI=locator.UserInterface;
    IAddressUI addressUI=locatorUI as IAddressUI;
    Int32 parentWindow=application.hWnd;
    string pathForGxBrowser="";
    IName name=addressUI.MatchTableFromSet(parentWindow, tableSet, table, true,
        locator, ref pathForGxBrowser);
}

ArcMap extensions

The ArcMap extension objects extend the ArcMap UI to provide geocoding functionality to ArcMap users.
The LocatorExtension object is an ArcMap application extension that manages the set of locators in an ArcMap document. The LocatorExtension object also responds to events that occur in the set of locators, such as the addition or removal of a locator from the ArcMap document.
The following code example illustrates how to use LocatorExtension to add a locator to an ArcMap document:
[VB.NET]
Public Sub AddLocatorToArcMap()
    
    ' Open an ArcSDE workspace.
    Dim propertieSetConnection As IPropertySet=New PropertySetClass
    With propertieSetConnection
        .SetProperty("server", "mendota")
        .SetProperty("instance", "esri_sde")
        .SetProperty("database", "arcobjects")
        .SetProperty("user", "sde")
        .SetProperty("password", "sde")
        .SetProperty("version", "SDE.Default")
    End With
    
    Dim workspaceFactory As IWorkspaceFactory=New SdeWorkspaceFactoryClass
    Dim workspace As IWorkspace=workspaceFactory.Open(propertieSetConnection, 0)
    
    ' Get a reference to the locator to add to the ArcMap document.
    Dim locatorManager As ILocatorManager=New LocatorManagerClass
    Dim locatorWorkspace As ILocatorWorkspace=locatorManager.GetLocatorWorkspace(workspace)
    Dim locator As ILocator=locatorWorkspace.GetLocator("SDE.Redlands Streets")
    
    ' Get a reference to the LocatorExtension.
    Dim locatorExtensionUID As UID=New UID
    locatorExtensionUID.Value="esriLocationUI.LocatorExtension"
    Dim application As IApplication=New AppRefClass
    Dim extension As IExtension=application.FindExtensionByCLSID(locatorExtensionUID)
    Dim locatorExtension As ILocatorExtension=TryCast(extension, ILocatorExtension)
    
    ' Add the locator to the LocatorExtension and set as the current locator.
    Dim locatorIndex As Int32=locatorExtension.AddLocator(locator)
    locatorExtension.CurrentLocator("Address")=locatorIndex
    
End Sub
[C#]
public void AddLocatorToArcMap()
{
    // Open an ArcSDE workspace.
    IPropertySet propertieSetConnection=new PropertySetClass();
    propertieSetConnection.SetProperty("server", "mendota");
    propertieSetConnection.SetProperty("instance", "esri_sde");
    propertieSetConnection.SetProperty("database", "arcobjects");
    propertieSetConnection.SetProperty("user", "sde");
    propertieSetConnection.SetProperty("password", "sde");
    propertieSetConnection.SetProperty("version", "SDE.Default");

    IWorkspaceFactory workspaceFactory=new SdeWorkspaceFactoryClass();
    IWorkspace workspace=workspaceFactory.Open(propertieSetConnection, 0);

    // Get a reference to the locator to add to the ArcMap document.
    ILocatorManager locatorManager=new LocatorManagerClass();
    ILocatorWorkspace locatorWorkspace=locatorManager.GetLocatorWorkspace
        (workspace);
    ILocator locator=locatorWorkspace.GetLocator("SDE.Redlands Streets");

    // Get a reference to the LocatorExtension.
    UID locatorExtensionUID=new UID();
    locatorExtensionUID.Value="esriLocationUI.LocatorExtension";
    IApplication application=new AppRefClass();
    IExtension extension=application.FindExtensionByCLSID(locatorExtensionUID);
    ILocatorExtension locatorExtension=extension as ILocatorExtension;

    // Add the locator to the LocatorExtension and set as the current locator.
    Int32 locatorIndex=locatorExtension.AddLocator(locator);
    locatorExtension.set_CurrentLocator("Address", locatorIndex);
}
The AddressFindData object represents a candidate returned by an address locator when the address locator is used in the Find dialog box in ArcMap. The AddressFindData object has properties that completely describe the candidate found by the address locator.