Select to view content in your preferred language

Custom Address Locator Add In

2320
5
Jump to solution
11-07-2012 09:43 AM
Corbinde_Bruin
Frequent Contributor
Hi all,

I'm looking to write an Add In in VB .NET that uses the same Address Search as ArcMap's native Find Tool, just tweaked. Is there any way to find some source code for the Find tool? All I'm seeing is the REST endpoint for for the North American Address Locator. I can't find any examples on this. A point in the right direction would be marvelous.


Thank you,
cdebruin
0 Kudos
1 Solution

Accepted Solutions
SteveFang
Deactivated User
According to the documentation.  The interface you're working with are under ESRI.ARCGIS.GISCLIENT lib.  Do you have that lib properly referenced in your project?

View solution in original post

0 Kudos
5 Replies
MichaelVolz
Esteemed Contributor
Try this Post to see if it provides some of the information that you are looking for in a slightly different application setting of ArcGIS Explorer

http://forums.arcgis.com/threads/22126-Can-I-use-an-Address-Locator-on-the-hard-drive-or-query-attri...
0 Kudos
Corbinde_Bruin
Frequent Contributor
I just found out that the all source code for ArcDesktop tools is available with the DeveloperKit (in both C# and VB.NET).
This is the particular file path on my machine:

C:\Program Files (x86)\ArcGIS\DeveloperKit10.1\Samples\ArcObjectsNet

So I just opened up the 'Find' tool here and I'm working on tweaking it's functionality.
0 Kudos
Corbinde_Bruin
Frequent Contributor
It seems I've either found some old code, or I just can't find the right reference. I'm looking to point to the North American Address Locator in VB.NET.
I'm using this example:

    Public Sub OpenAGSLocatorWorkspace()

        ' Open an ArcGIS Server connection.
        Dim propertySet As IPropertySet = New PropertySetClass

        propertySet.SetProperty("machine", "mendota")

        Dim obj As System.Object = Activator.CreateInstance(Type.GetTypeFromProgID("esriGISClient.AGSServerConnectionFactory"))
        Dim agsServerConnectionFactory As IAGSServerConnectionFactory = CType(obj, IAGSServerConnectionFactory)
        Dim agsServerConnection As IAGSServerConnection = agsServerConnectionFactory.Open(propertySet, 0)

        obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"))
        Dim locatorManager2 As ILocatorManager2 = CType(obj, ILocatorManager2)
        Dim Name As IName = agsServerConnection.FullName

        Dim agsServerConnectionName As IAGSServerConnectionName = CType(Name, IAGSServerConnectionName)
        Dim locatorWorkspace As ILocatorWorkspace = locatorManager2.GetAGSLocatorWorkspace(agsServerConnectionName)

        ' Open the AGSLocatorWorkspace
        Dim agsLocatorWorkspace As IAGSLocatorWorkspace = CType(locatorWorkspace, IAGSLocatorWorkspace)

    End Sub


Visual Basic gives me an error of type not defined on all the red objects
0 Kudos
SteveFang
Deactivated User
According to the documentation.  The interface you're working with are under ESRI.ARCGIS.GISCLIENT lib.  Do you have that lib properly referenced in your project?
0 Kudos
MichaelVolz
Esteemed Contributor
From the following link:

http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriLocation/Get_ArcGIS_Server_locator.htm


Public Function GetAGSAddressLocator(strServerName As String, strLocatorName As String) As esriGeoDatabase.ILocator'+++ returns a locator retrieved from an ArcGIS Server
Dim pConnectionProperties As esriSystem.IPropertySet
Dim pAGSServerConnectionFactory As esriGISClient.IAGSServerConnectionFactory
Dim pAGSServerConnectionName As esriGISClient.IAGSServerConnectionName
Dim pLocatorManager As esriLocation.ILocatorManager2
Dim pLocatorWorkspace As esriGeoDatabase.ILocatorWorkspace

'+++ open an ArcGIS Server connection to the specified server machine
Set pConnectionProperties = New esriSystem.PropertySet
pConnectionProperties.SetProperty "machine", strServerName
Set pAGSServerConnectionFactory = New esriGISClient.AGSServerConnectionFactory
Set pAGSServerConnectionName = pAGSServerConnectionFactory.Open(pConnectionProperties, 0).FullName

'+++ retrieve a LocatorWorkspace from the ArcGIS Server connection
Set pLocatorManager = New esriLocation.LocatorManager
Set pLocatorWorkspace = pLocatorManager.GetAGSLocatorWorkspace(pAGSServerConnectionName)

'+++ return the locator with the specified name
Set GetAGSAddressLocator = pLocatorWorkspace.GetLocator(strLocatorName)
End Function
0 Kudos