AnsweredAssumed Answered

How to use Multiple Sources in Search Widget

Question asked by namoraj96 on Sep 19, 2018
Latest reply on Oct 9, 2018 by kawish

    Can anyone 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 search-fields in it.

So 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");

Outcomes