LocatorSearchSource

AMD: require(["esri/widgets/Search/LocatorSearchSource"], (LocatorSearchSource) => { /* code goes here */ });
ESM: import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource";
Class: esri/widgets/Search/LocatorSearchSource
Inheritance: LocatorSearchSource SearchSource Accessor
Since: ArcGIS API for JavaScript 4.0

The following properties define a source pointing to a Locator that may be used to geocode locations with a Search widget instance.

See also:

Constructors

new LocatorSearchSource(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Stringmore details

An authorization string used to access a resource or service.

more detailsLocatorSearchSource
Booleanmore details

Indicates whether to automatically navigate to the selected result once selected.

more detailsSearchSource
String[]more details

A string array which limits the results to one or more categories.

more detailsLocatorSearchSource
Stringmore details

Constricts search results to a specified country code.

more detailsLocatorSearchSource
Stringmore details

The name of the class.

more detailsAccessor
Numbermore details

Sets the scale of the MapView or SceneView for the resulting search result, if the locator service doesn’t return an extent with a scale.

more detailsLocatorSearchSource
Objectmore details

This property replaces the now deprecated searchQueryParams, suggestQueryParams, and searchExtent properties.

more detailsLocatorSearchSource
GetResultsHandlermore details

Function used to get search results.

more detailsSearchSource
GetSuggestionsParametersmore details

Function used to get search suggestions.

more detailsSearchSource
Stringmore details

Defines the type of location, either street or rooftop, of the point returned from the World Geocoding Service.

more detailsLocatorSearchSource
Locatormore details

The locator task used to search.

more detailsLocatorSearchSource
Numbermore details

Indicates the maximum number of search results to return.

more detailsSearchSource
Numbermore details

Indicates the maximum number of suggestions to return for the widget's input.

more detailsSearchSource
Numbermore details

Indicates the minimum number of characters required before querying for a suggestion.

more detailsSearchSource
Stringmore details

The name of the source for display.

more detailsLocatorSearchSource
String[]more details

Specifies the fields returned with the search results.

more detailsSearchSource
Stringmore details

Used as a hint for the source input text.

more detailsLocatorSearchSource
Booleanmore details

Indicates whether to display a Popup when a selected result is clicked.

more detailsSearchSource
PopupTemplatemore details

The popup template used to display search results.

more detailsSearchSource
Stringmore details

Specify this to prefix the user's input of the search text.

more detailsSearchSource
Booleanmore details

Indicates whether to show a graphic on the map for the selected source using the resultSymbol.

more detailsSearchSource
Symbolmore details

The symbol used to display the result.

more detailsSearchSource
Stringmore details

A template string used to display multiple fields in a defined order when results are displayed.

more detailsLocatorSearchSource
Stringmore details

The field name of the Single Line Address Field in the REST services directory for the locator service.

more detailsLocatorSearchSource
Stringmore details

Specify this to add a suffix to the user's input for the search value.

more detailsSearchSource
Booleanmore details

Indicates whether to display suggestions as the user enters input text in the widget.

more detailsLocatorSearchSource
Booleanmore details

Indicates whether to constrain the search results to the view's extent.

more detailsSearchSource
Numbermore details

The set zoom scale for the resulting search result.

more detailsLocatorSearchSource

Property Details

apiKey String
Since: ArcGIS API for JavaScript 4.19

An authorization string used to access a resource or service. API keys are generated and managed in the ArcGIS Developer dashboard. An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage. Setting a fine-grained API key on a specific class overrides the global API key.

Example:
const searchWidget = new Search({
  view: view,
  includeDefaultSources: false,
  sources: [{
    name: "apiKey locator",
    placeholder: "APIs are Key",
    apiKey: "abcdefghijklmnopqrstuvwxyz",
    locator: new Locator({
      url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
    })
  }]
});
autoNavigate Boolean inherited

Indicates whether to automatically navigate to the selected result once selected.

Default Value:true
categories String[]

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.

See also:
countryCode String

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.

See also:
declaredClass Stringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

defaultZoomScale Number
Since: ArcGIS API for JavaScript 4.13

Sets the scale of the MapView or SceneView for the resulting search result, if the locator service doesn’t return an extent with a scale. An example of this is using the Use current location option in the Search bar.

If you want to override the scale returned by the locator service, use zoomScale instead.

Default Value:null
Example:
// create the Search widget
let searchWidget = new Search({
  view: view
});

// wait for the widget to be ready to set the defaultZoomScale
searchWidget.watch("viewModel.state", function(state) {
  if (state === "ready") {
    let firstSource = searchWidget.allSources.getItemAt(0);
    if (firstSource) {
      firstSource.defaultZoomScale = 100000;
    }
  }
});
filter Object
Since: ArcGIS API for JavaScript 4.4

This property replaces the now deprecated searchQueryParams, suggestQueryParams, and searchExtent properties. Setting a value here takes precedence over withinViewEnabled. Please see the object specification table below for details.

Property:
geometry Geometry
optional

The filter geometry for suggests or search results. Extent is the only supported geometry when working with locator sources. See Find Address Candidates for additional information.

See also:
Example:
const theExtent = new Extent({
  xmin: 11376463,
  ymin: -5163501,
  xmax: 18890529,
  ymax: -662888,
  spatialReference: {
    wkid: 3857
  }
});

const searchExtent = {
  geometry: theExtent
};

const sources = [{
  locator: new Locator({
     url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
  }),
  placeholder: "Darwin",
  maxResults: 3,
  filter: searchExtent
}];

const searchWidget = new Search({
  view: view,
  sources: sources
});

Function used to get search results. See GetResultsHandler for the function definition. When resolved, returns an object containing an array of search results.

Default Value:null
See also:

Function used to get search suggestions. See GetSuggestionsParameters for the function definition. When resolved, returns an object containing an array of suggest results.

Default Value:null
See also:
locationType String
Since: ArcGIS API for JavaScript 4.12

Defines the type of location, either street or rooftop, of the point returned from the World Geocoding Service.

Possible Values:"rooftop"|"street"

Example:
// create the Search widget
let searchWidget = new Search({
  view: view
});

// wait for the widget to be ready to set the locationType
searchWidget.watch("viewModel.state", function(state) {
  if (state === "ready") {
    let firstSource = searchWidget.allSources.getItemAt(0);
    if (firstSource) {
      firstSource.locationType = "rooftop";
    }
  }
});
locator Locator

The locator task used to search. This is required and defaults to the World Geocoding Service.

maxResults Number inherited

Indicates the maximum number of search results to return.

Default Value:6
maxSuggestions Number inherited

Indicates the maximum number of suggestions to return for the widget's input.

Default Value:6
minSuggestCharacters Number inherited

Indicates the minimum number of characters required before querying for a suggestion.

Default Value:1
name String

The name of the source for display.

outFields String[] inherited

Specifies the fields returned with the search results.

placeholder String

Used as a hint for the source input text.

popupEnabled Boolean inherited

Indicates whether to display a Popup when a selected result is clicked.

popupTemplate PopupTemplate inherited

The popup template used to display search results. If no popup is needed, set the source's popupTemplate to null.

This property should be set in instances where there is no existing PopupTemplate configured. For example, feature sources will default to any existing popupTemplate configured on the layer.

prefix String inherited

Specify this to prefix the user's input of the search text.

resultGraphicEnabled Boolean inherited

Indicates whether to show a graphic on the map for the selected source using the resultSymbol.

resultSymbol Symbol inherited

The symbol used to display the result.

Known Limitations

This property only applies when the layer/locator/source is not part of the map.

searchTemplate String

A template string used to display multiple fields in a defined order when results are displayed.

Example:
locatorLayerSource.searchTemplate = "{County}, {State}";
singleLineFieldName String

The field name of the Single Line Address Field in the REST services directory for the locator service. Common values are SingleLine and SingleLineFieldName.

suffix String inherited

Specify this to add a suffix to the user's input for the search value.

suggestionsEnabled Boolean

Indicates whether to display suggestions as the user enters input text in the widget.

Default Value:true
withinViewEnabled Boolean inherited

Indicates whether to constrain the search results to the view's extent.

Default Value:false
zoomScale Number

The set zoom scale for the resulting search result. This scale is automatically honored.

Default Value:null
Example:
let searchWidget = new Search({
  view: view,
  includeDefaultSources: false,
  sources: [
    {
      locator: new Locator({
        url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
      }),
      name: "LocatorSearchSource",
      zoomScale: 500000
    }
  ]
});

Method Overview

Name Return Type Summary Class
LocatorSearchSourcemore details

Creates a deep clone of this object.

more detailsLocatorSearchSource
*more details

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

more detailsLocatorSearchSource
Objectmore details

Converts an instance of this class to its ArcGIS portal JSON representation.

more detailsLocatorSearchSource

Method Details

Creates a deep clone of this object.

Returns:
Type Description
LocatorSearchSource A clone of the new LocatorSearchSource instance.
fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter:
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns:
Type Description
* Returns a new instance of this class.
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns:
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.