If a web map has search enabled in the application settings, is it possible to remove those sources in the map component?
I would like the search source to only be a default one created from AGOL world geocoding. I figured out how to add the AGOL LocatorSearchSource to the search component, and I can make it the first option with the active-source-index property. However, the other options from the web map remain. This is an issue as one of the locators will prompt public users for credentials if selected.
I feel like I'm missing something simple that would allow for only the default source to be used for searching.
Search | ArcGIS Maps SDK for JavaScript
Solved! Go to Solution.
Yes — you can. In the Search map component, the web map’s configured search sources are used unless you override them.
To force only the World Geocoder (and prevent the web map sources from showing up), do two things:
Disable default/webmap sources in the UI
Use include-default-sources-disabled="true" (this stops defaultSources from being included).
Esri Developer
Explicitly set sources to only your locator
Once sources is set, the component won’t fall back to allSources from the web map.
Esri Developer
Example:
<arcgis-search
include-default-sources-disabled="true"
active-source-index="0">
</arcgis-search>
import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource.js";
const search = document.querySelector("arcgis-search");
search.sources = [
new LocatorSearchSource({
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",
name: "World Geocoder"
})
];
If you still see the secured locator after this, it usually means sources wasn’t actually being set (or it’s being appended elsewhere). But the supported approach is: disable default sources + set sources explicitly.
Yes — you can. In the Search map component, the web map’s configured search sources are used unless you override them.
To force only the World Geocoder (and prevent the web map sources from showing up), do two things:
Disable default/webmap sources in the UI
Use include-default-sources-disabled="true" (this stops defaultSources from being included).
Esri Developer
Explicitly set sources to only your locator
Once sources is set, the component won’t fall back to allSources from the web map.
Esri Developer
Example:
<arcgis-search
include-default-sources-disabled="true"
active-source-index="0">
</arcgis-search>
import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource.js";
const search = document.querySelector("arcgis-search");
search.sources = [
new LocatorSearchSource({
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",
name: "World Geocoder"
})
];
If you still see the secured locator after this, it usually means sources wasn’t actually being set (or it’s being appended elsewhere). But the supported approach is: disable default sources + set sources explicitly.