GeoCoder Service doesn't work for Directions widget

410
2
10-28-2021 05:10 AM
benchikh
New Contributor III

Hi,

Im working with Directions widget under arcgis api 3.38 and want to change the GeoCoder service URL to work with my own GeoCoder service, but it doesnt work , knowing that if I used the esri GeoCoder service it works correctly

var sources = [
{
locator: new Locator("https://xxxxxxx/arcgis/rest/services/Adress_Locator/GeocodeServer"),
locationToAddressTemplate: "${City}, ${State}, ${Country}",
singleLineFieldName: "SingleLine",
outFields: ["City"],
localSearchOptions: {
minScale: 300000,
distance: 50000
}

}
];
var options = {
sources: sources
};
//default will point to ArcGIS world routing service
var directions = new Directions({
map: map,
showClearButton: true,
showSegmentPopup: false,
directionsLengthUnits: "esriMiles",
mapClickActive: true,
routeTaskUrl: "https://xxxxxxxxx/arcgis/rest/services/CALCUL_ITINERAIRE/NAServer/Route",
searchOptions: options
}, "dir");
directions.startup();

 

Could you please help me with that ?

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

It's difficult to tell from the code snippet. Couple questions that might help troubleshoot:

What do you mean by doesn't work? Is there an error message in the console? What does the network request to the locator look like? Are you sure the locator is working properly? Is the locator service configured to handle the defined property values correctly? 

0 Kudos
benchikh
New Contributor III

Hi,

It means that when I put my own GeoCoder code and enter an origin/Destination I got "no result found" message in the widget, and no error message appears on in the console.

I can confirm the locator(My GeoCoder) works fine as I have already tested it in an App Builder application.

 

otherwise ,  I have solved the issue by working with a FeatureLayer instead of Locator like this:

var sourcesLayer = [
{

featureLayer: new FeatureLayer("https://xxxxxxxxxx/arcgis/rest/services/TEST_SPATIAL/MapServer/0"),
searchFields: ["DesignationPointTransport"],
suggestionTemplate: "${DesignationPointTransport}",
exactMatch: false,
outFields: ["*"],
name: "Senators",
labelSymbol: "t",
placeholder: "Senator name",
maxResults: 6,
maxSuggestions: 6,
enableSuggestions: true,
minCharacters: 0,
localSearchOptions: { distance: 50000 }

}
];