Hide Table of Contents
Search widget

The Search widget provides easy map navigation by adding a search box. This search box enables users to move to a location much quicker and easier than standard panning/zooming. It provides search capabilities based on a given locator service and/or feature layers. The Search widget is similar to the Geocoder widget. The main difference is that it provides additional functionality that allows searching and suggestions from multiple sources.

var search = new Search({
  map: map
},"search");
search.startup();

This widget wraps pre-built search functionality directly in it so all you need to do is reference it within your application. The widget defaults to the ArcGIS Online World Geocoding service if nothing is specified. It can also be customized to work with another defined locator. In addition to locators, the Search widget has the ability to search layers within your map and/or feature service. You specify how you wish the widget to work by using either a locator, feature layer(s), or both. These are considered sources of the widget and can be set in the sources property.

The sources property indicates what is searchable within the search box. If using a locator with a geocoding service, the findAddressCandidates operation is used. Whereas queries are used on feature layers.

Once a result is selected, an associated infoTemplate is displayed with the result. All of this is customizable as well. A sample showing this can be found here.

This widget provides properties such as whether you wish to have the results automatically navigate to search results, enable suggestions for possible search results, and whether you want to automatically search layers from the map. For a full listing of available options, please see the API reference.

NOTE: Working with suggestions is only available if working with a 10.3 geocoding service that has the suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true.

The information provided here is just a sample of the widget's functionality. See the Search widget API reference for additional information on this. In addition, please refer to the following examples of web applications that use this widget.

  1. Search basic
  2. Search multiple sources
  3. Search with customization
  4. Search using a suggestion template
Show Modal