AnsweredAssumed Answered

Get layer name from search result object (3.24)

Question asked by PSLarkin_SpokaneCounty on May 14, 2018
Latest reply on May 14, 2018 by PSLarkin_SpokaneCounty

I'd like to get the name of the layer returned from a Search Widget result. I can get the name property from the result object, but I'm wondering if there is a cleaner way. The documentation doesn't cover the result object in detail so it is difficult to tell what a Best Practice might be. 

 

 

This will return the layer name used as a source for the Search Widget.

on(search, 'search-results', function (e) {
    e.results[0][0].feature._layer.name
});

Outcomes