I keep just getting:
'esri/widgets/Search'
Search
// SEARCH WIDGET
const sources = [];
sources.push({
featureLayer: new FeatureLayer({
url: 'OurServer/MapServer/2',
}),
name: 'Service Point',
displayField: 'gs_name',
outFields: ['*'],
searchFields: ['gs_name'],
placeholder: 'Search for customer information.',
maxResults: 3
});
const searchWidget = new Search({
view: view,
sources: sources,
includeDefaultSources: false,
});
view.ui.add(searchWidget, {
position: 'top-left',
index: 0,
});
Super simple, but it just doesn't work. I don't see any network requests either.
Any idea what could be wrong here?
Solved! Go to Solution.
I found out what was wrong not too long after posting, but for some reason I couldn't find this post, so I thought it was deleted or something.
Anyway, the problem is that featureLayer has been changed to just layer now. Once I made that change, then it worked.
sources.push({
layer: new FeatureLayer({
url: 'OurServer/MapServer/2',
}),
name: 'Service Point',
displayField: 'gs_name',
outFields: ['*'],
searchFields: ['gs_name'],
placeholder: 'Search for customer information.',
maxResults: 3
});
There doesn't seem to be anything wrong with what you have as far as I can tell. However, changes made to the Search widget in 4.25 have caused some folks to notice *apparently* missing results, so If you're upgrading from a version prior to 4.25, you might check out this thread.
I found out what was wrong not too long after posting, but for some reason I couldn't find this post, so I thought it was deleted or something.
Anyway, the problem is that featureLayer has been changed to just layer now. Once I made that change, then it worked.
sources.push({
layer: new FeatureLayer({
url: 'OurServer/MapServer/2',
}),
name: 'Service Point',
displayField: 'gs_name',
outFields: ['*'],
searchFields: ['gs_name'],
placeholder: 'Search for customer information.',
maxResults: 3
});