Select to view content in your preferred language

Search Component and includeDefaultSources

91
1
Jump to solution
a week ago
D_Atkins
Regular Contributor

We're trying to remove the default ArcGIS World Geocoding Service from the Search Component, and replacing with our own layers and locators. 

1. Legacy documentation suggests passing an empty list of sources first; this does not work (and probably shouldn't).   Solved: How to hide "Esri World Geocoder" in the search wi... - Esri Community

2. More contemporary discussion suggests setting the .includeDefaultSources property to 'false'.  The sample documentation illustrates this working by setting a property during a call to the widget's Constructor. Solved: How do I disable the ArcGIS World Geocoding Servic... - Esri Community

3. Now with Components, we're able to follow this Search component with multiple sources to get our custom searches defined.  But, the Geocoding Service appears above any local results, and we'd like to remove results from halfway across the globe: from Console.log, we find the '.includeDefaultSources' property as undefined and setting the property to false has no effect on the Search widget.   

We could step back to using the Constructors over the Components, but it seems like there should be a better way forward?

Any suggestions?

0 Kudos
1 Solution

Accepted Solutions
fdeters
Regular Contributor

Hi @D_Atkins, I just went through this same issue recently. It sounds like you're looking for the Search component's 'includeDefaultSourcesDisabled' property, which has the corresponding 'include-default-sources-disabled' attribute. Here's the documentation link: https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-search/#includeDefa...

In your HTML, you can do this to remove the Esri geocoding service from the Search component:

<arcgis-search
    id="searchbar"
    include-default-sources-disabled
></arcgis-search>

 

If you prefer to set it via JavaScript, I think (but do not know) that this would work:

const search = document.querySelector('#searchbar')
search.includeDefaultSourcesDisabled = true;

 

View solution in original post

1 Reply
fdeters
Regular Contributor

Hi @D_Atkins, I just went through this same issue recently. It sounds like you're looking for the Search component's 'includeDefaultSourcesDisabled' property, which has the corresponding 'include-default-sources-disabled' attribute. Here's the documentation link: https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-search/#includeDefa...

In your HTML, you can do this to remove the Esri geocoding service from the Search component:

<arcgis-search
    id="searchbar"
    include-default-sources-disabled
></arcgis-search>

 

If you prefer to set it via JavaScript, I think (but do not know) that this would work:

const search = document.querySelector('#searchbar')
search.includeDefaultSourcesDisabled = true;