AnsweredAssumed Answered

Using Search widget to query on locator source, but bring up featurelayer data in popup.

Question asked by steve.peralta_COLeg on Mar 28, 2018
Latest reply on Apr 9, 2018 by steve.peralta_COLeg

Here's what I have so far. 4.6 API. Any help appreciated!!

Kelly Hutchins

 

// Search widget
var searchWidget = new Search({
view: view,
sources: [{
locator: new Locator({ url: locatorServiceUrl }),
singleLineFieldName: "SingleLine",
name: "Place",
localSearchOptions: {
minScale: 300000,
distance: 50000
},
placeholder: "Search Places",
maxResults: 3,
maxSuggestions: 6,
suggestionsEnabled: true,
popupEnabled: false,
minSuggestCharacters: 0
},
{
featureLayer: houseLyr,
searchFields: ["LAST_NAME", "DISTRICT"],
displayField: "LAST_NAME",
exactMatch: false,
outFields: ["*"],
name: "House Members",
maxResults: 10,
maxSuggestions: 10,
suggestionsEnabled: true,
minSuggestCharacters: 0,
placeholder: "District No. or Last Name"
},
{
featureLayer: senateLyr,
searchFields: ["LAST_NAME", "DISTRICT"],
displayField: "LAST_NAME",
exactMatch: false,
outFields: ["*"],
name: "Senate Members",
placeholder: "District No. or Last Name",
maxResults: 6,
maxSuggestions: 6,
suggestionsEnabled: true,
minSuggestCharacters: 0
}]

});

searchWidget.on("select-result", function(event){
//DEBUG
console.log(JSON.stringify(event));
if(!event.result.feature.geometry.rings)
{
view.popup.open({
title: "Feature Layer data!",
content: "Want that data here.",
location: event.result.feature.geometry
});
}
});

Outcomes