I am working on adding a search bar to my code and found this amazing source (Search multiple sources | ArcGIS API for JavaScript ) that allows one to search over multiple fields using the same search bar. The only issue is that the search in this code produces a single result (i.e there is only one congressional district that is 'district 6')
I want to use this tool for searching trees. So rather than "Congressional District" I want to search "Common Tree Name"
I am inquiring about how to change the one search result to be a result that shows all of the points that share that tree name.
Any help would be Awesome!
-Adam
Adam,
you need to configure the sources to match your data:
sources.push({
featureLayer: new FeatureLayer("http://yourtreeserviceURL/FeatureServer/0"),
searchFields: ["CommonTreeName"],
displayField: "CommonTreeName",
exactMatch: true,
name: "tree",
outFields: ["*"],
placeholder: "Tree name",
maxResults: 6,
maxSuggestions: 6,
//Create an InfoTemplate
infoTemplate: new InfoTemplate("Tree information", "Name: ${Name}"),
enableSuggestions: true,
minCharacters: 0
});
Regards
Anthony
See I did that and it works fine. I can type in "Tulip Tree" and it identifies A tulip tree. It only shows one of the many tulip trees in the data. So as far as that is concerned the search bar works fine. I just want the search for 'tulip tree' to display ALL of the tulip trees (i.e. 50 point results rather than just 1 result)
Adam,
The search bar isn't really designed to do what you want to achieve, you really need to use a query task:
QueryTask | API Reference | ArcGIS API for JavaScript
Unfortunately I cannot see any samples that show you how to simply use this combined with a map.
Have a look at the configurable map viewer that might give you some pointers:
Regards
Anthony
Adam,
you could could also try the find task:
Find features on a map | ArcGIS API for JavaScript
Regards
Anthony