AnsweredAssumed Answered

search multiple sources

Question asked by mprindiville_gis on Jan 19, 2017
Latest reply on Jan 20, 2017 by MCooney-esristaff

I've added the search multiple sources code sample located https://developers.arcgis.com/javascript/3/jssamples/search_multiplesources.html.  however it doesn't appear to search the feature layer.  It does search the world geocode service but not the feature layer.  Any ideas on what I am missing.

 

I've added the District Feature Layer to the map and can see the Search box.

 

var sources = search.get("sources");

//Push the sources used to search, by default the ArcGIS Online World geocoder is included. In addition there is a feature layer of US congressional districts. The districts search is set up to find the "DISTRICTID". Also, a feature layer of senator information is set up to find based on the senator name.

sources.push({
featureLayer: new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServer/0"),
searchFields: ["DISTRICTID"],
displayField: "DISTRICTID",
exactMatch: false,
outFields: ["DISTRICTID", "NAME", "PARTY"],
name: "Congressional Districts",
placeholder: "3708",
maxResults: 6,
maxSuggestions: 6,

//Create an InfoTemplate and include three fields
infoTemplate: new InfoTemplate("Congressional District", "District ID: ${DISTRICTID}</br>Name: ${NAME}</br>Party Affiliation: ${PARTY}"),
enableSuggestions: true,
minCharacters: 0
});

//Set the sources above to the search widget
search.set("sources", sources);

search.startup();
});

-melissa

Outcomes