Hi, I'm trying to use the Search widget with the option to return multiple results (autoSelect: false). This means results won't automatically be populated into my popup, and I must handle that. The popup's setFeatures method takes a deferred. I've been trying to research what this means really but I don't quite understand. The Search widget is returning an array of results; how do I turn that into a deferred and set it as the popup's features?
I understand that creating a deferred object would reference a function. I see and understand how this works with the Identify here. But in this case, as far as I can tell no function is required to return the results? Results are returned on the Search widget's event 'search-results'. Should the Search method itself be a deferred object?
Here's my guess at how I thought it might go, which doesn't work:
enableSearchingAll: false,
autoSelect: false,
map: mapObj,
maxResults: 100,
maxSuggestions: 100
}, "search");
var searchDeferred = s
.execute()
.addCallback(function(e){
s.startup();
});
s.on('search-results', function(e){
console.log('search results: ', e.results);
console.log(e.numResults);
mapObj.infoWindow.setFeatures(searchDeferred);
mapObj.infoWindow.show(e.mapPoint);
});
Trying to run the above results in Uncaught TypeError: s.execute is not a function
I have a jsfiddle here, any pointers are greatly appreciated.