Skip to content
import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource.js";
Inheritance:
LocatorSearchSourceSearchSourceAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

The following properties define a source pointing to a url that represents a locator service, which may be used to geocode locations with a Search widget or Search component.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
autoNavigate
inherited
declaredClass
readonly inherited
getResults
inherited
getSuggestions
inherited
maxResults
inherited
maxSuggestions
inherited
outFields
inherited
popupEnabled
inherited
popupTemplate
inherited
prefix
inherited
resultSymbol
inherited
suffix
inherited
uid
readonly inherited
url
withinViewEnabled
inherited

apiKey

Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.19

An authorization string used to access a resource or service. API keys are generated and managed in the portal. 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 searchElem = document.querySelector("arcgis-search");
await searchElem.componentOnReady();
searchElem.sources = [{
name: "apiKey locator",
placeholder: "APIs are Key",
apiKey: "YOUR_API_KEY",
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
}];

autoNavigate

inherited Property
Type
boolean | null | undefined
Inherited from: SearchSource

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

Default value
true

categories

Property
Type
string[] | null | undefined

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

Property
Type
string | null | undefined

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

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

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

defaultZoomScale

Property
Type
number | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.13

Sets the scale of the MapView.scale or SceneView.scale 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.

Example
// wait for Search to be ready to set the defaultZoomScale
reactiveUtils.when(
() => search.state === "ready",
() => {
let firstSource = search.allSources.at(0);
if (firstSource) {
firstSource.defaultZoomScale = 100000;
}
}
);

filter

Property
Type
SearchFilter | null | undefined
Since
ArcGIS Maps SDK 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.

See also
Examples
const theExtent = new Extent({
xmin: 11376463,
ymin: -5163501,
xmax: 18890529,
ymax: -662888,
spatialReference: {
wkid: 3857
}
});
const searchElem = document.querySelector("arcgis-search");
await searchElem.componentOnReady();
searchElem.sources = [{
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
placeholder: "Carmen Sandiego",
maxResults: 3,
filter: searchExtent
}];
const theExtent = new Extent({
xmin: 11376463,
ymin: -5163501,
xmax: 18890529,
ymax: -662888,
spatialReference: {
wkid: 3857
}
});
const searchExtent = {
geometry: theExtent,
where: "TERRITORY = 'Northern Territory'"
};
const sources = [{
layer: featureLayerTourism,
placeholder: "Darwin",
maxResults: 5,
searchFields: ["POI"],
displayField: "POI",
name: "In a Sunburned Country",
filter: searchExtent
}];
const searchWidget = new Search({
view: view,
sources: sources
});

getResults

inherited Property
Type
GetResultsCallback | null | undefined
Inherited from: SearchSource

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

See also

getSuggestions

inherited Property
Type
GetSuggestionsCallback | null | undefined
Inherited from: SearchSource

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

See also

language

Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.34

This property defines the preferred language for reverse geocoded results (if supported by the locator service at the geolocated location). If null, the default language of the geocoded country will be used. Similarly, the default language will be used if the parsed language is not supported in that geocoded country.

See also
Example
// Return addresses in Spanish (if supported at the geolocated location)
const search = new Search({
view,
includeDefaultSources: false,
sources: [
{
apiKey: "YOUR_API_KEY",
language: "es", // Spanish
name: "ArcGIS World Geocoding Service",
placeholder: "Find address or place",
singleLineFieldName: "SingleLine",
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
}
]
});

localSearchDisabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.22

This property controls prioritization of Search result candidates depending on the view scale.

When this property is false (the default value), the location parameter is included in the request when the scale of the MapView.scale or SceneView.scale is less than or equal to 300,000. This prioritizes result candidates based on their distance from a specified point (the center of the view).

When this property is true, the location parameter is never included in the request, no matter the scale of the MapView.scale or SceneView.scale.

Default value
false
Example
const searchElem = document.querySelector("arcgis-search");
await searchElem.componentOnReady();
searchElem.sources = [{
name: "ArcGIS World Geocoding Service",
placeholder: "example: Campton, NH",
apiKey: "YOUR_API_KEY",
singleLineFieldName: "SingleLine",
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
localSearchDisabled: true
}];

locationType

Property
Type
LocationType | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.12

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

Example
// wait for Search to be ready to set the locationType
reactiveUtils.when(
() => search.state === "ready",
() => {
let firstSource = search.allSources.at(0);
if (firstSource) {
firstSource.locationType = "rooftop";
}
}
);

maxResults

inherited Property
Type
number | null | undefined
Inherited from: SearchSource

Indicates the maximum number of search results to return.

Default value
6

maxSuggestions

inherited Property
Type
number | null | undefined
Inherited from: SearchSource

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

Default value
6

minSuggestCharacters

inherited Property
Type
number | null | undefined
Inherited from: SearchSource

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

name

Property
Type
string

The name of the source for display.

Default value
""

outFields

inherited Property
Type
string[] | null | undefined
Inherited from: SearchSource

Specifies the fields returned with the search results.

placeholder

Property
Type
string | null | undefined

Used as a hint for the source input text.

Default value
""

popupEnabled

inherited Property
Type
boolean | null | undefined
Inherited from: SearchSource

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

popupTemplate

autocast inherited Property
Type
PopupTemplate | null | undefined
Inherited from: SearchSource

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 FeatureLayer.popupTemplate configured on the layer.

prefix

inherited Property
Type
string
Inherited from: SearchSource

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

Default value
""

resultGraphicEnabled

inherited Property
Type
boolean | null | undefined
Inherited from: SearchSource

Indicates whether to show a graphic on the map for the selected source using the resultSymbol. If using a LayerSearchSource, then this property only applies when the LayerSearchSource is not part of the map.

resultSymbol

inherited Property
Type
SymbolUnion | null | undefined
Inherited from: SearchSource

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

Property
Type
string

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

Default value
""
Example
locatorLayerSource.searchTemplate = "{County}, {State}";

singleLineFieldName

Property
Type
string | null | undefined

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

inherited Property
Type
string
Inherited from: SearchSource

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

Default value
""

suggestionsEnabled

Property
Type
boolean | null | undefined

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

Default value
true

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

url

Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.22

URL to the ArcGIS Server REST resource that represents a locator service. This is required.

Example
const searchElem = document.querySelector("arcgis-search");
await searchElem.componentOnReady();
searchElem.sources = [{
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
}];

withinViewEnabled

inherited Property
Type
boolean
Inherited from: SearchSource

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

Default value
false

zoomScale

Property
Type
number | null | undefined

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

Examples
const searchElem = document.querySelector("arcgis-search");
await searchElem.componentOnReady();
searchElem.sources = [{
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
name: "LocatorSearchSource",
zoomScale: 500000
}];
let searchWidget = new Search({
view: view,
sources: [
{
layer: featureLayer,
searchFields: ["Name", "Team"],
name: "LayerSearchSource",
zoomScale: 500000
}
]
});

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone(): LocatorSearchSource
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

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.

Parameters
ParameterTypeDescriptionRequired
json
any

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
any

Returns a new instance of this class.

clone

Method
Signature
clone (): LocatorSearchSource

Creates a deep clone of this object.

Returns
LocatorSearchSource

A clone of the new LocatorSearchSource instance.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

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

Returns
any

The ArcGIS portal JSON representation of an instance of this class.