Select to view content in your preferred language

How to add a locator via sdk ?

4282
20
11-08-2018 07:34 AM
servicesigu
Occasional Contributor

Hi,

I want to know how to add a locator from a server (ie a geocoding service).

The purpose is to give our users our own locators, when a project is opened.

Thanks in advance for your reply.

0 Kudos
20 Replies
BradNiemand
Esri Regular Contributor

You can have this functionality by adding the geocoding services as Utility Services in ArcGIS Enterprise.  This must be done by the administrator but once it is done, all users will see these locators loaded by default when signed in.  More about this can be found here:

Configure utility services—Portal for ArcGIS (10.6) | ArcGIS Enterprise 

Brad

JamalWest2
Regular Contributor

Is there any other way to do this outside of Portal?

0 Kudos
NarelleChedzey
Esri Contributor

Take a look at the LocatorManager class available from the active map view.   It allows you to add locators 

https://pro.arcgis.com/en/pro-app/sdk/api-reference/index.html#topic18887.html

Here's an example snippet

internal async Task<bool> AddLocator()
{
   ArcGIS.Desktop.Mapping.Geocoding.LocatorProvider lp = await               

                MapView.Active.LocatorManager.AddLocatorAsync("D:\\Data\\Geocode\\ACT.loc");

  //ArcGIS.Desktop.Mapping.Geocoding.LocatorProvider lp = await MapView.Active.LocatorManager.AddLocatorAsync(@"https://xxx/server/rest/services/yyy/GeocodeServer");
return true;
}

JamalWest2
Regular Contributor

I have tried to do this. I am attempting to use a locator service. When I add it to the project I can see it added but it is greyed out and unusable. The only thing I can do with it is remove it.

0 Kudos
JamalWest2
Regular Contributor

Do you have any suggestions or ideas as to why this maybe. I'm not getting any errors anywhere.

0 Kudos
BradNiemand
Esri Regular Contributor

Jamal,

What type of locator are you adding to Pro?  Can you do it via Pro without error?  When you open the Locate Pane, click on the settings tab and hover over the locator does it give you any type of warning or error?

Brad

0 Kudos
JamalWest2
Regular Contributor

This is a Locator Service published to ArcServer 10.6.1. Yes I can add it to the project and LOcators manually. I can aadd it both direct from server connection and a server connection file.

0 Kudos
BradNiemand
Esri Regular Contributor

Jamal,

What path is showing in Pro when you hover over the locator in the Locators folder in the Catalog Pane?  Are you using the same path when you are adding it via the SDK?

For instance, when I add a locator via the Server connection:

I see a path like this:

C:\path\arcgis on servermachine_6080\name_of_locator.GeocodeServer

Is this how you are entering the path?

Brad

0 Kudos
JamalWest2
Regular Contributor

Yes only no 6080, we are using a webAdaptor. That is the syntax being used. C:\{path}\arcgis on {serverpath}\Locators(Folder)\{LocatorName}.GeocodeServer. I verified the path and connection work by adding it manually(using Add Locator) in ArcGIS pro.

0 Kudos