There’s a new way to easily search your mapping data.
The ArcGIS JavaScript API’s new Search dijit precedes the Geocoder dijit (now deprecated). It’s been re-imagined, renamed and redesigned to provide a single searching and suggestion experience. It allows you to search across multiple Locator and Feature Layer services from a simple interface.
Whereas the Geocoder dijit’s intention was for searching only Locator tasks, the Search dijit was designed to handle multiple types of “sources,” including Locator tasks, Feature Layers and potentially more. The user interface has also been improved to handle searching one more of these sources. With the Search dijit, you can search or get suggestions from all the defined sources or a single source.
Much of the same functionality found in the Geocoder widget is also present in the Search dijit, but many new features have been added and redesigned for a better user and developer experience. As a developer, it should be easier for you to configure the Search widget and less code to write in order to handle common searching tasks. The icons for the widget use a font, so properties like the color or size can easily be modified.
New Features include:
Have fun exploring the demos or implementing it in your app.
How I do it is that I simply don't declare s.set("activeSourceIndex", 0); This for me will simply select ALL as the default. I set my sources though but don't pick which one I want and as such it defaults to ALL.
Interesting -- that approach isn't working for me. If I don't set activeSourceIndex, the first geocoder in the list (after All) is selected.
But I can do this:
s.set("activeSourceIndex","all);
and "All" is selected by default.
I would like to change the "placeholder" for the "All" selection from "Find address or place name" to just "Place name". I can't figure out how to change the placeholder for the "All" selection. I do know where to change it for the other feature layer sources that I specified.
You can set the "allPlaceholder" property on the widget. I'll get that doc'd.
Perfect!
Is it possible to disable the 'All' search option?
Yes, set the "enableSourcesMenu" to false.
Yes I've read the documentation, maybe my question wasn't clear. I need the sources menu so that I can offer multiple layers from our server to search. However, a user must choose a layer. I do not want there to be an "All" option in the sources menu.
Oh ok. I'll make an enhancement request for that. Currently, if you have multiple sources, you can choose between a source or "All". I'll have to add an option for "All" to be disabled.