Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: Search

dojo.require("esri.dijit.Search");

Description

(Added at v3.13)
The Search widget provides a way to perform search capabilities based on locator service(s) and/or map/feature service feature layer(s). These specified sources determine 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.

The Search widget is similar to the Geocoder widget. The main difference is that it provides additional functionality that allows searching and suggestions on multiple sources. Suggestions are available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e. supportsPagination = true. Also, if using the Esri locator, suggest does not have an option to return a number of suggestions.

Note: When using a Map with a SpatialReference other than Web Mercator or Geographic, be sure to set a default GeometryService. This will ensure that the user's position is returned in the same SpatialReference as the Map.
require(["esri/config"], function(esriConfig) {
  esriConfig.defaults.geometryService = "http://www.example.com/arcgis/rest/services/Utilities/Geometry/GeometryServer";
});

Samples

Search for samples that use this class.

Constructors

NameSummary
new esri.dijit.Search(options, srcNode)Create a new Search widget using the given DOM node.

CSS

esri/dijit/Search | Download source

NameDescription
activeClass used to describe the style for the active "Search" button and resulting menu items.
arcgisSearchRepresents an instance of the node where the Search widget is rendered. This is the default theme used to uniquely style the widget.
hasButtonModeClass indicating whether button mode is displayed.
hasMultipleSourcesClass indicating whether multiple sources are being used.
hasValueClass which indicates if there is input text in the widget.
menuHeaderClass used to style the top header of the search results in the menu.
moreHeaderClass used to style the "More Results" section in the resulting search popup.
moreResultsClass used to indicate whether to display additional results in the resulting search popup.
noResultsBodyClass used to style the body of how "No results" is displayed.
noResultsHeaderClass used to style the header of how "No results" displays.
noResultsMenuClass used to style the menu if there are "No results".
noResultsTextThe class used to style the "No results" text.
noValueIconThis class is used used if wanting to display a warning icon when no value is entered into the search box.
noValueTextClass used to style the resulting dialog when no value is entered in the search box.
popupHeaderClass used to style the popupHeader in the search popup's "More results".
resultsListClass used to style the popup's search results list.
searchAnimateClass used to style how the search animation displays.
searchBtnClass used to style the Search button.
searchButtonTextThe class used to style how the "Search" button displays its text.
searchClearThe class used to style the "Clear search" (x) area of the widget.
searchClearFloatUsed to clear floats in the Search widget.
searchClearIcon | esriIconCancelClass used to style the clear icon.
searchCollapsedClass used to indicate whether the search is collapsed.
searchExpandContainerContaining class for when the widget is expanded.
searchExpandedClass used to indicate whether the search is expanded.
searchGroupClass used to style the elements used for the input text and search.
searchIcon | esriIconZoomClass used to style the search icon.
.arcgisSearch .searchIcon {
      color:orange;
      font-size:20px;
}
searchInputClass used to style the search input box.
searchInputGroupClass used to style the grouping of input elements.
searchLoadingClass used to indicate that the search is loading.
searchMenuClass used to style the resulting search results menu.
searchSubmitClass used to style the Search's submit button when collapsed.
searchToggleClass used to style how the toggle button displays.
searchToggleIcon | esriIconDownDirClass used to style the toggle icon.
.arcgisSearch .esriIconDownDir{
     color: #ccc;
}
showMoreResultsClass used to indicate if showing more results in the search result popup.
showNoResultsClass indicating whether to display "No results".
showSourcesClass indicating whether to display sources.
showSuggestionsClass indicating whether to show suggestions for text input.
sourceNameClass used to style how the source name is displayed.
sourcesMenuClass used to style the drop-down menu listing all available sources.
suggestionsMenuClass used to style the drop-down menu for suggestions.

Properties

NameTypeSummary
activeSourceObjectRead-only property of the source object currently selected.
activeSourceIndexNumberThe currently selected source.
addLayersFromMapBooleanIndicates whether to automatically add all the feature layers from the map.
allPlaceholderStringThis is the default value used as a hint for input text when searching on multiple sources.
autoNavigateBooleanIndicates whether to automatically navigate to the selected result.
autoSelectBooleanIndicates whether to automatically select the first geocoded result.
defaultSourceObject(Read-only), the default source used for the Search widget.
enableButtonModeBooleanIndicates whether to enable an option to collapse/expand the search into a button.
enableHighlightBooleanShow the selected feature on the map using a default symbol determined by the source's geometry type.
enableInfoWindowBooleanIndicates whether to display the infoWindow on feature click.
enableLabelBooleanIndicates whether to enable showing a label for the geometry.
enableSearchingAllBooleanIndicates whether to display the option to search "All" sources.
enableSourcesMenuBooleanIndicates whether to enable the menu for selecting different sources.
enableSuggestionsBooleanEnable suggestions for the widget.
NOTE: This is available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e.
enableSuggestionsMenuBooleanIndicates whether to display suggest results.
NOTE: Suggestions are available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e.
expandedBooleanIndicates whether to set the state of the enableButtonMode to expanded (true) or collapsed (false).
graphicsLayerLayerThis is the specified graphicsLayer to use for the highlightGraphic and labelGraphic instead of map.graphics.
highlightGraphicGraphicRead-only property indicating the highlighted location graphic.
infoTemplateInfoTemplateA customized infoTemplate for the selected feature.
labelGraphicGraphicRead-only graphic property for the text label.
labelSymbolTextSymbolThe text symbol for the label graphic.
loadedBooleanRead-only property indicating whether the widget is loaded.
locationToAddressDistanceNumberThe default distance specified in meters used to reverse geocode (if not specified by source).
mapMapReference to the map.
maxResultsNumberThe default maximum number of results returned by the widget if not specified by source.
maxSuggestionsNumberThe default maximum number of suggestions returned by the widget if not specified by source.
minCharactersNumberThe default minimum number of characters needed for the search if not specified by source.
searchResultsObject[]Read-only property that returns an array of current results from the search.
showInfoWindowOnSelectBooleanIndicates whether to show the infoWindow when a result is selected.
sourcesObject[]An array of source objects used to find search results.
suggestResultsObject[]Read-only property that returns an array of current results from the suggest.
suggestionDelayNumberThe millisecond delay after keyup and before making a suggest network request.
themeStringThe CSS class selector used to uniquely style the widget.
valueStringThe current value of the search box input text string.
visibleBooleanIndicate whether to show the widget.
zoomScaleNumberIf the result does not have an associated extent, specify this number to use as the zoom scale for the result.

Methods

NameReturn typeSummary
blur()NoneUnfocus the widget's text input.
clear()NoneClears the current value, search results, suggest results, graphic, and/or graphics layer.
collapse()NoneCloses the widget from button mode.
destroy()NoneDestroys the Search widget.
expand()NoneOpens the widget from button mode.
focus()NoneBrings focus to the widget's text input.
get(name)Object | Boolean | Layer | Graphic | InfoTemplate | Number | TextSymbol | Map | Array | StringGet the value of the property from the Search widget.
hide()NoneHides the Search widget.
search(value?)PromiseDepending on the sources specified, search() queries the feature layer(s) and/or performs address matching using any specified Locator(s) and returns any applicable results.
select(value)NoneSelects a result.
set(name, value)NoneSets the value of a non "read-only" property from the widget.
show()NoneShow the Search widget.
startup()NoneFinalizes the creation of the Search widget.
suggest(value?)PromisePerforms a suggest() request on the active Locator or feature layer.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
blurFired when the widget's text input loses focus.
clear-searchFired when a result is cleared from the input box or a new result is selected.

Please note that Internet Explorer fires this event if either sources or activeSourceIndex properties are set via the set method..
focusFired when the widget's text input sets focus.
loadFired when the search widget has fully loaded.
search-results
{
  activeSourceIndex: <Number>,
  errors: <Error[]>,
  numErrors: <Number>,
  numResults: <Number>,
  results: <Object[]>,
  value: <String>
}
Fires when the search method is called and returns its results.
select-result
{
  result: <Object>,
  source: <Object>,
  sourceIndex: <Number>
}
Fired when a search result is selected.
suggest-results
{
  activeSourceIndex: <Number>,
  errors: <Error[]>,
  numErrors: <Number>,
  numResults: <Number>,
  results: <Object[]>,
  value: <String>
}
Fired when the suggest method is called and returns its results.
Constructor Details

new esri.dijit.Search(options, srcNode)

Create a new Search widget using the given DOM node.
Parameters:
<Object> options Required Set of options used to specify Search options. This parameter is required but can be null or an empty object. See the options properties below for details.
<Node | String> srcNode Required Reference or id of the HTML element where the widget should be rendered.
options properties:
<Number | String> activeSourceIndex Optional The currently selected source. The default is "all".
<Boolean> addLayersFromMap Optional Indicates whether to automatically add all the feature layers from the map. The default value is false.
<String> allPlaceholder Optional This is the default value used as a hint for input text when searching on multiple sources. The default value is "Find address or place".
<Boolean> autoNavigate Optional Indicates whether to automatically navigate to the selected result. The default value is true.
<Boolean> autoSelect Optional Indicates whether to automatically select the first geocoded result (not the first suggestion). The default value is true.
<Boolean> enableButtonMode Optional Indicates whether to enable an option to collapse/expand the search into a button. The default value is false.
<Boolean> enableHighlight Optional Indicates whether to show the selected feature on the map using the highlight symbol property. The default value is true.
<Boolean> enableInfoWindow Optional Indicates whether to display the infoWindow on feature click. The default value is true. See the enableInfoWindow property for additional information on this.
<Boolean> enableLabel Optional Indicates whether to enable showing a label for the geometry.The default value is false.
<Boolean> enableSearchingAll Optional Indicates whether to display the option to search "All" sources. Default is true.
<Boolean> enableSourcesMenu Optional Indicates whether to enable the menu for selecting different sources. The default value is true.
<Boolean> enableSuggestions Optional Indicates whether or not to enable suggest on the widget. The default value is true.
NOTE: This is available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e. supportsPagination = true.
<Boolean> enableSuggestionsMenu Optional Indicates whether to display suggest results. The default value is true.
<Boolean> expanded Optional Indicates whether to set the state of the enableButtonMode to expanded (true) or collapsed (false). The default value is false.
<Layer> graphicsLayer Optional This the specified graphicsLayer to use for the highlightGraphic and labelGraphic instead of map.graphics.
<InfoTemplate> infoTemplate Optional A customized infoTemplate for the selected feature.
NOTE: Do not specify a wildcard "${*}" for this specific infoTemplate as it will return all fields in addition to search-specific fields.
<TextSymbol> labelSymbol Optional The text symbol for the label graphic.
<Number> locationToAddressDistance Optional The default distance specified in meters used to reverse geocode, (if not specified by source). The default value is 1500.
<Map> map Optional Reference to the map. If no map is specified, the value is null.
<Number> maxResults Optional The default maximum number of results returned by the widget if not specified by source. The default value is 6.
<Number> maxSuggestions Optional The default maximum number of suggestions returned by the widget if not specified by source. The default value is 6. NOTE: If working with the default ArcGIS Online Geocoding service, the default remains at 5.
<Number> minCharacters Optional The default minimum amount of characters needed for the search if not specified by source. The default value is 1.
<Boolean> showInfoWindowOnSelect Optional Indicates whether to show the infoWindow when a result is selected. The default value is true. See the showInfoWindowOnSelect property for additional information on this.
<Object[]> sources Optional An array of source objects used to find search results. Refer to the sources property for additional information on this.
<Number> suggestionDelay Optional The millisecond delay after keyup and before making a suggest network request. The default value is 150.
<String> theme Optional The CSS class selector used to uniquely style the widget. The default value is arcgisSearch.
<String> value Optional Current value of the search box input text string. The default value is "".
<Boolean> visible Optional Indicates whether to show the Search widget. Default value is true.
<Number> zoomScale Optional If the result does not have an associated extent, specify this number to use as the zoom scale for the result. The default value is 1000.
Sample:
var s = new esri.dijit.Search({map: map },"search");
Property Details

<Object> activeSource

Read-only property of the source object currently selected. Can be either a feature layer or locator task.

<Number> activeSourceIndex

The currently selected source. The default is 0. When sources is set(), activeSourceIndex will be set to 0 if the sources length is 1. Otherwise, it will be set to "all".

Please note that Internet Explorer fires a clear-search event if either the sources property or this property is set via the set method. (Added at v3.14)

<Boolean> addLayersFromMap

Indicates whether to automatically add all the feature layers from the map.
Default value: false

<String> allPlaceholder

This is the default value used as a hint for input text when searching on multiple sources. The default value is "Find address or place". (Added at v3.15)
Default value: "Find address or place"

<Boolean> autoNavigate

Indicates whether to automatically navigate to the selected result.
Default value: true

<Boolean> autoSelect

Indicates whether to automatically select the first geocoded result. If false, the findAddressCandidates operation will still geocode the input string, but the top result will not be selected. To work with the geocoded results, you can set up a search-results event handler and get the results through the event object.
Default value: true

<Object> defaultSource

(Read-only), the default source used for the Search widget. (Added at v3.15)
Default value: ArcGIS Online World Geocoding Service

<Boolean> enableButtonMode

Indicates whether to enable an option to collapse/expand the search into a button.
Default value: false

<Boolean> enableHighlight

Show the selected feature on the map using a default symbol determined by the source's geometry type.
Default value: true

<Boolean> enableInfoWindow

Indicates whether to display the infoWindow on feature click. The graphic can be clicked to display an info window. This is not the same as using showInfoWindowOnSelect which opens the info window any time a search is performed.

Note: It is possible to have showInfoWindowOnSelect=false but enableInfoWindow=true so that the info window can be opened by someone but it is not open by default.
Default value: true

<Boolean> enableLabel

Indicates whether to enable showing a label for the geometry.
Default value: false

<Boolean> enableSearchingAll

Indicates whether to display the option to search "All" sources. Default is true. (Added at v3.15)
Default value: true

<Boolean> enableSourcesMenu

Indicates whether to enable the menu for selecting different sources.
Default value: true

<Boolean> enableSuggestions

Enable suggestions for the widget.
NOTE: This is available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e. supportsPagination = true.
Default value: true

<Boolean> enableSuggestionsMenu

Indicates whether to display suggest results.
NOTE: Suggestions are available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e. supportsPagination = true.
Default value: true

<Boolean> expanded

Indicates whether to set the state of the enableButtonMode to expanded (true) or collapsed (false).
Default value: false

<Layer> graphicsLayer

This is the specified graphicsLayer to use for the highlightGraphic and labelGraphic instead of map.graphics.

<Graphic> highlightGraphic

Read-only property indicating the highlighted location graphic.

<InfoTemplate> infoTemplate

A customized infoTemplate for the selected feature.

NOTE: Do not specify a wildcard "${*}" for this specific infoTemplate as it will return all fields in addition to search-specific fields.

<Graphic> labelGraphic

Read-only graphic property for the text label.

<TextSymbol> labelSymbol

The text symbol for the label graphic.

<Boolean> loaded

Read-only property indicating whether the widget is loaded.

<Number> locationToAddressDistance

The default distance specified in meters used to reverse geocode (if not specified by source). (Added at v3.15)
Default value: 1500

<Map> map

Reference to the map. If not map specified, value is null.

<Number> maxResults

The default maximum number of results returned by the widget if not specified by source.
Default value: 6

<Number> maxSuggestions

The default maximum number of suggestions returned by the widget if not specified by source. NOTE: If working with the default ArcGIS Online Geocoding service, the default remains at 15.
Default value: 6

<Number> minCharacters

The default minimum number of characters needed for the search if not specified by source.
Default value: 1

<Object[]> searchResults

Read-only property that returns an array of current results from the search.

<Boolean> showInfoWindowOnSelect

Indicates whether to show the infoWindow when a result is selected. Using showInfoWindowOnSelect opens the info window any time a search is performed.

Note: It is possible to have showInfoWindowOnSelect=false but enableInfoWindow=true so that the info window can be opened by someone but it is not open by default.
Default value: true

<Object[]> sources

An array of source objects used to find search results.

Multiple geocoding services are supported in addition to searching feature layers. See the object specifications table below for the structure of the sources object.

Default sources[]
[
  {
    locator: new   Locator("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
    singleLineFieldName: "SingleLine",
    outFields: ["Addr_type"],
    name: i18n.widgets.Search.main.esriLocatorName,
    localSearchOptions: {
      minScale: 300000,
      distance: 50000
    },
    placeholder: i18n.widgets.Search.main.placeholder,
    highlightSymbol: new PictureMarkerSymbol(this.basePath + "/images/search-pointer.png", 36, 36).setOffset(9, 18)
  }
]

Example sources[]

 var sources = [
  {
     locator: ,
     locationType: "street",
     singleLineFieldName: "SingleLine", 
     name: "Custom Geocoding Service",
     localSearchOptions: {
     minScale: 300000,
     distance: 50000
     },
     placeholder: "Search Geocoder",
     maxResults: 3,
     maxSuggestions: 6,
     enableSuggestions: false,
     minCharacters: 0
}, {
     featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"),
    searchFields: ["Name", "Party"],
    suggestionTemplate: "${Name}, Party: ${Party}",
    exactMatch: false,
    outFields: ["*"],
    name: "Senators",
    labelSymbol: textSymbol,
    placeholder: "Senator name",
    maxResults: 6,
    maxSuggestions: 6,
    enableSuggestions: true,
    minCharacters: 0,
    localSearchOptions: {distance: 5000},
   },
   {
     featureLayer: new FeatureLayer(),{
        outFields: ["*"]
     });
     placeholder: "esri",
     name: "A FeatureLayer",
     prefix: "",
     suffix: "",
     maxResults: 1,
     maxSuggestions: 6,
     exactMatch: false, 
     searchFields: [], // defaults to FeatureLayer.displayField
     displayField: "", // defaults to FeatureLayer.displayField
     labelSymbol: new TextSymbol(), 
     minCharacters: 0 
   }
];

There are a few ways to set the sources:
  • Set source(s) on creation
       var s = new Search({
          sources: []
          });
          s.startup();
    
  • Add to sources
       var s = new Search();
       var sources = s.get("sources");
       sources.push({//new source});
       s.set("sources", sources);
       s.startup();
    
  • Set sources
       var s = new Search();
       var sources = [my sources];
       s.set("sources", sources);
       s.startup();
    
Please note that Internet Explorer fires a clear-search event if either sources or activeSourceIndex properties are set via the set method.

When working with multiple sources, there may be instances when needing to listen for when the source changes. If this is the case, the following snippet of code will do this:
  search.watch("activeSourceIndex", function(){
  var activeSource = search.activeSource//.name;
  console.log("Current Source", activeSource);
});

Default value: ArcGIS Online World Geocoding Service
Object Specifications:
<localSearchOptions>
<Number> distance Required Specify a search distance for the location search. The default value is 12,000 meters.
<Number> minScale Required Location search will be performed when the map scale is less than the specified value. The default minScale is 15,000.
<sources>
<Boolean> autoNavigate Required Applies to both locators and feature layer sources. This indicates whether to automatically navigate to the selected result once selected. The default is true.
<String[]> categories Required A string array which limits the results to one or more categories. For example "Populated Place" or "airport". Only applicable when using the World Geocode Service. View the World Geocoding Service documentation for more information.
<String> countryCode Required Applies only when working with locator sources. This constricts search results to a specified country code. For example, "US" for United States or "SE" for Sweden. Only applies to the World Geocode Service. View the World Geocoding Service documentation for more information.
<String> displayField Required Applies to only feature layer sources. The results are displayed using this field. Defaults to the layer's displayField or the first string field.
<Boolean> enableHighlight Required Applies to both locators and feature layer sources. This indicates whether to show a graphic on the map for the selected source using its highlightSymbol. The default value is true.
<Boolean> enableInfoWindow Required Applies to both locators and feature layer sources. It displays an info window when a selected result is clicked. The default is true.
<Boolean> enableLabel Required Applies to both locators and feature layer sources. This indicates whether to show a text label on the map for the selected source using labelSymbol. The default value is false.
<Boolean> enableSuggestions Required Applies to both locators and feature layer sources. This indicates whether to enable suggestions for the widget user input. The default value is true.

NOTE: This is available if working with a 10.3 geocoding service that has suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true.
<Boolean> exactMatch Required Applies only to feature layer source. This only return results that match the search value exactly. Default is false .
<FeatureLayer> featureLayer Required This applies only to map service feature layer sources. The feature layer is queried in the search. If searching feature layers, this is required.
<String> highlightSymbol Optional The symbol used for highlightGraphic. If not specified, it renders using smart mapping defaults.
<InfoTemplate> infoTemplate Required The InfoTemplate used for the selected result. This applies to both locators and feature layer sources.
<TextSymbol> labelSymbol Required The TextSymbol used to label the selected result. This applies to both locators and feature layer sources.
<Object> localSearchOptions Optional Applies only when working with locator sources. This is used to set the sources for local distance and minScale for searching. See the localSearchOptions table below for details.
<Number> locationToAddressDistance Optional The default distance specified in meters used to reverse geocode. The default is 1500.
<String> locationType Optional Define the type of location, either "street" or "rooftop", of the point returned from the World Geocoding Service.
<Locator> locator Required This applies only to locator sources. It is the locator task used to search. This is required and defaults to the World Geocoding Service.
<Number> maxResults Required Applies to both locators and feature layer sources. This number indicates the maximum number of results to return. The default value is 6.
<Number> maxSuggestions Required Applies to both locators and feature layer sources. This number indicates the maximum number of suggestions to return for the widget's input. The default value is 15.
<Number> minCharacters Required Applies to both locators and feature layer sources. This number indicates the minimum number of characters required before querying for a suggestion. The default value is 1.
<String> name Required Applies to both locators and feature layer sources. This is the name of the source for display.
<String[]> outFields Required This string array applies to both locators and feature layer sources. It specifies the fields returned with the search results.
<String> placeholder Required Applies to both locators and feature layer sources. This is used as a hint for the source input text. Not supported by IE9 and below.
<String> prefix Required Applies to both locators and feature layer sources. Specify this to prefix the input for the search text.
<String[]> searchFields Required Applies only to feature layer sources. It is an array of string values to search for results within these feature layer fields.
<String> searchTemplate Optional (Added at v. 3.15) Applicable when working with reverse geocoding. A template string used to customize the value for the returned geocoded address. It provides flexibility with how the string gets constructed, i.e. what fields are used, in which order, and with which delimiters.
NOTE: It is important to note that if a searchTemplate is not specified, the geocoded address may not display as expected, for example coordinates instead of an address string. Also, field names must use the following convention in the string: "${FieldName}".
<Boolean> showInfoWindowOnSelect Required Applies to both locators and feature layer sources. This indicates whether to show the info window when a result is selected. The default value is true.
<String> singleLineFieldName Required This applies only to locator sources. It is the field name of the Single Line Address Field in the REST services directory for the locator service. Common values are "SingleLine" and "SingleLineFieldName".
<String> suffix Required Applies to both locators and feature layer sources. Specify this to suffix the input for the search text.
<String> suggestionTemplate Optional (Added at v. 3.14) A template string used to display multiple fields in a defined order. This only works with feature layer sources and takes precedence over displayField.
<Boolean> useMapExtent Required Indicates whether to constrain the search results to the map's extent.
<Number> zoomScale Optional Applicable to the specified source. If the result does not have an associated extent, specify this number to use as the zoom scale for the result.

<Object[]> suggestResults

Read-only property that returns an array of current results from the suggest.
NOTE: This is available if working with a 10.3 or later geocoding service that has suggest capability loaded or a 10.3 or later feature layer that supports pagination, i.e. supportsPagination = true.

<Number> suggestionDelay

The millisecond delay after keyup and before making a suggest network request.
Default value: 150

<String> theme

The CSS class selector used to uniquely style the widget.
Default value: arcgisSearch

<String> value

The current value of the search box input text string.
Default value: ""

<Boolean> visible

Indicate whether to show the widget.
Default value: true

<Number> zoomScale

If the result does not have an associated extent, specify this number to use as the zoom scale for the result.
Default value: 1000
Method Details

blur()

Unfocus the widget's text input.

clear()

Clears the current value, search results, suggest results, graphic, and/or graphics layer. It also hides any open menus.

collapse()

Closes the widget from button mode. This requires enableButtonMode to be true.

destroy()

Destroys the Search widget. Call destroy() when the widget is no longer needed by the application.

expand()

Opens the widget from button mode. It requires enableButtonmode to be true.

focus()

Brings focus to the widget's text input.

get(name)

Get the value of the property from the Search widget. Full list of properties provided in the Properties listed for this class.
Parameters:
<String> name Required String value indicating the property to get.

hide()

Hides the Search widget.

search(value?)

Depending on the sources specified, search() queries the feature layer(s) and/or performs address matching using any specified Locator(s) and returns any applicable results. The search() uses whatever the current value is set for the widget, or if desired, a value can be passed to it.
Return type: Promise
Parameters:
<String | Geometry | Object | Number[]> value Optional This value can be a string, geometry, suggest candidate object, or an array of [latitude,longitude].

If a geometry is supplied, then it will reverse geocode (locator) or findAddressCandidates with geometry instead of text (featurelayer).

select(value)

Selects a result.
Parameters:
<Object> value Required The result object to select.

set(name, value)

Sets the value of a non "read-only" property from the widget.
Parameters:
<String> name Required The string value to set.
<Object | Boolean | Layer | Graphic | InfoTemplate | Number | TextSymbol | Map | Array | String> value Required The value to set the specified property to.

show()

Show the Search widget.

startup()

Finalizes the creation of the Search widget. Call startup() after creating the widget when you are ready for user interaction.

suggest(value?)

Performs a suggest() request on the active Locator or feature layer. It also uses the current value of the widget or one that is passed in.
NOTE: Suggestions are available if working with a 10.3 geocoding service that has suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true.
Return type: Promise
Parameters:
<String> value Optional The string value used to suggest() on an active locator or feature layer. If nothing is passed in, takes the current value of the widget.
Event Details
[ On Style Events | Connect Style Event ]

blur

Fired when the widget's text input loses focus.
Sample:
require([
...
], function( ... )
   on(s,'blur', function(e) {
      console.log ('blur');
      });
   ...
});

clear-search

Fired when a result is cleared from the input box or a new result is selected.

Please note that Internet Explorer fires this event if either sources or activeSourceIndex properties are set via the set method.
Sample:
require([
...
], function( ... )
   on(s,'clear-search', function(e) {
      console.log ('cleared search');
      });
   ...
});

focus

Fired when the widget's text input sets focus.
Sample:
require([
...
], function( ... )
   on(s,'focus', function(e) {
      console.log ('focus');
      });
   ...
});

load

Fired when the search widget has fully loaded.

search-results

Fires when the search method is called and returns its results.
Event Object Properties:
<Number> activeSourceIndex The activeSourceIndex of the search result.
<Error[]> errors An array of error objects returned from the search result.
<Number> numErrors The number of errors returned from the search.
<Number> numResults The number of results from the search.
<Object[]> results An array of objects representing the results of the search.
{
  results: [
    extent: <Extent>,
    feature: <Feature>
  ]
}
<String> value The string value of the returned search result.
Sample:
require([
...
], function( ... )
   on(s,'search-results', function(e) {
      console.log ('search results', e);
      });
   ...
});

select-result

Fired when a search result is selected.
Event Object Properties:
<Object> result An object containing the results of the search.
{
  extent: <Extent>, 
  feature: <Graphic>,
  name: <String>
}

<Object> source The source of the selected result. Please see sources for additional information on its properties.
<Number> sourceIndex The source index of the selected result.
Sample:
require([
...
], function( ... )
   on(s,'select-result', function(e) {
      console.log ('selected result', e);
      });
   ...
});

suggest-results

Fired when the suggest method is called and returns its results.
Event Object Properties:
<Number> activeSourceIndex The activeSourceIndex of the suggest result.
<Error[]> errors An array of error objects returned from the suggested result.
<Number> numErrors The number of errors from the suggest.
<Number> numResults The number of suggest results.
<Object[]> results An array of objects containing the results of suggest().
{
  results: [
    isCollection: <Boolean>,
    magicKey: <String>,
    text: <String>
  ]
}
<String> value The string value of the returned suggest result.
Sample:
require([
...
], function( ... )
   on(s,'suggest-results', function(e) {
      console.log ('suggest results', e);
      });
   ...
});
Show Modal