The following code shows our attempt to add all locators found in our Portal (Enterprise 11.3) to the active project in ArcGIS Pro (3.3.1).
public async void AddLocators(MapView mapView, CancelableProgressorSource progress)
{
await QueuedTask.Run(async () =>
{
var portal = ArcGISPortalManager.Current.GetActivePortal();
PortalQueryParameters query = PortalQueryParameters.CreateForItemsOfType(PortalItemType.GeocodingService);
LocatorManager lm = mapView.LocatorManager;
do
{
PortalQueryResultSet<PortalItem> portalResults = await ArcGISPortalExtensions.SearchForContentAsync(portal, query);
if (portalResults.Results.Count <= 0) break;
progress.Max =(uint) portalResults.Results.Count;
foreach (var item in portalResults.Results.OfType<PortalItem>())
{
await lm.AddLocatorAsync(item.Path);
progress.Progressor.Value += 1;
}
query = portalResults.NextQueryParameters;
} while (query != null);
}, progress.Progressor);
}
The code completes successfully with one issue... The results shown in the catalog pane have two rows for every locator found. (attached file is a screenshot showing the results in catalog pane.)
The first row has a path ending in GeocodeServer (ex. https://<host>/<context>/rest/services/Locators/Locator_AllFeaturesGISID/GeocodeServer). This version of the locator is what I would consider more correct as its path matches what we see in Rest Service Directory. But it is not functional in ArcPro.
The second row has the service name repeated at the end (ex. https://<host>/<context>/rest/services/Locators/Locator_AllFeaturesGISID/GeocodeServer/Locator_AllFeaturesGISID). This locator is functional in ArcPro and matches the path of a locator the was manually added to the project using pro's Add Locator tool/command.
Anyone care to take a stab at what might be causing the weird results?