Using v4.7 of the JavaScript API:
I add two feature layers to a map (sourced on .json data files). The layers show up fine, with the data expected, and selectable/deselectable using the LayersList widget.
When I try to setup the Search widget, both layers appear in the select dropdown list ok, but when I enter some text to search I don't get any hits and the auto-suggestions are also not appearing. I think that map.layers[0] and map.layers[1] are not referencing the actual layers (I also tried map.layers[8] and map.layers[9] - which don't exist - and got no errors).
When I look at the JavaScript console, and run a
console.log("Results of the search: ", event)
I see in Results / Source: featureLayer: undefined
but
searchFields: ["name"] so (some of) the parameters sent below are getting through.
The fieldname to search in is "name". Any help to resolve this would be appreciated. Here's the code:
var searchSources =[
{ featureLayer: map.layers[0], searchFields: ["name"], displayField: "name", exactMatch: false, outFields: ["*"], name: "A search", placeholder: "A search", maxResults: 6, maxSuggestions: 6, suggestionsEnabled: true, minSuggestCharacters: 0 },
{ featureLayer: map.layers[1], searchFields: ["name"], displayField: "name", exactMatch: false, outFields: ["*"], name: "B search", placeholder: "B search", maxResults: 6, maxSuggestions: 6, suggestionsEnabled: true, minSuggestCharacters: 0 }];
var search = new Search({ map: map, allPlaceholder: "Search A and B", sources: searchSources });
view.ui.add(search, {position: "top-right", });