JS API 4.9 : cannot remove Esri World Geocoder from Directions widget

626
2
11-27-2018 11:21 AM
NicolasGIS
Occasional Contributor III

Hello,

I know directions widget of 4.9 is still in beta but I think it would be interesting to be able to remove the default ESRI world geocoder from the search sources of the widget just like what we can do currently with the property includeDefaultSources of the search.

Currently, defining the sources of the search in the searchProperties property do not overwrite the default ESRI world geocoder but append it and I was not able to find an easy way to remove it as the searches are not "accessible" as a property of the widget. 

I tried to set my source as default with the activeSourceIndex property, but it seems like it is not taken into account.

In the meantime, if you have any idea for a workaround, that would be great !

Thanks,

0 Kudos
2 Replies
JoshWerts
New Contributor III

Did you find a solution to this?

0 Kudos
NicolasGIS
Occasional Contributor III

Oups, apologize for my late reply, I missed that question.

I did find a workaround. The idea is to push your locator in the directionSources property, disable searchAll setting in the Directions widget by setting "searchAllEnabled" property to false and by specifying that the source "activeSourceIndex" is 0.

Here is a snippet:

/* Directions configuration */
const directionSources = new Collection<LocatorSearchSource>();
directionSources.add(
new LocatorSearchSource({
locator: new Locator({
url:
"https://company.com/arcgis/rest/services/Adresses/GeocodeServer"
}),
singleLineFieldName: "ZIPCode",
placeholder: "33 ESRI Road",
outFields: ["Addr_type"],
name: "CustomLocator"
})
);

this.directionsWidget = new Directions({
view,
routeServiceUrl:
"https://company.com/arcgis/rest/services/Network/NAServer/Route",
searchProperties: {
sources: directionSources,
searchAllEnabled: false,
activeSourceIndex: 0
}
});
Hope that help
0 Kudos