Hi All,
my search widget uses both geocoding service and two feature sources. However, I m having trouble having , it highlights the ESRI geocoder as the first source of search instead of ALL.
How do I make the ALL the default search so it searches all sources. Thanks in advance
Solved! Go to Solution.
Henry,
The help docs say that you set the activeIndex to -1 to search all layers:
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#activeSource
The selected source's index. This value is
-1
when all sources are selected.
Henry,
The help docs say that you set the activeIndex to -1 to search all layers:
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#activeSource
The selected source's index. This value is
-1
when all sources are selected.
Hi Robert,
Can you please tell me how to use below array of sources
var searchWidget = new Search(); var sources = [{ ... }, { ... }, { ... }]; //array of sources
searchWidget.sources = sources;
when we want to search multiple layers which having same name search-fields in it.
So in widget we can search it using search fields not with selecting feature layer.
right now am using it like below
const searchWidget = new Search({
view: view,
locationEnabled: true,
withinViewEnabled: true,
sources: [{
featureLayer: {
Placeholder: "OBJID",
url: "------------------------------------------",
popupTemplate: PopupTemp1
},
searchFields: ["OBJID", "TRACKNUM"],
suggestionTemplate: "{OBJID}, {TRACKNUM}",
exactMatch: true,
outFields: ["*"],
placeholder: "eg: SD0051S Or 2336767 or ",
zoomScale: 5000,
resultSymbol: {
type: "simple-line",
color: "black",
width: 8,
cap: "round",
style: "short-dashdotdot"
}
},
{
featureLayer: {
url: "-------------------------------------------",
popupTemplate: PopupTemp2
},
searchFields: ["OBJID", "TRACKNUM"],
suggestionTemplate: "{OBJID}, {TRACKNUM}",
exactMatch: true,
outFields: ["*"],
placeholder: "eg:SD0051S Or 2336767",
zoomScale: 5000,
resultSymbol: {
type: "simple-line",
color: "black",
width: 8,
cap: "round",
style: "short-dashdotdot"
}
}]
}, "SearchDivOpen", "top-right");