LocatorSearchSource

AMD: require(["esri/widgets/Search/LocatorSearchSource"], (LocatorSearchSource) => { /* code goes here */ });
ESM: import LocatorSearchSource from "@arcgis/core/widgets/Search/LocatorSearchSource.js";
Class: esri/widgets/Search/LocatorSearchSource
Inheritance: LocatorSearchSource→SearchSource→Accessor
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 instance.

See also

Constructors

LocatorSearchSource

Constructor
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

An authorization string used to access a resource or service.

LocatorSearchSource

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

SearchSource

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

LocatorSearchSource

Constricts search results to a specified country code.

LocatorSearchSource

The name of the class.

Accessor

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.

LocatorSearchSource

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

LocatorSearchSource

Function used to get search results.

SearchSource

Function used to get search suggestions.

SearchSource

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

LocatorSearchSource

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

LocatorSearchSource

Indicates the maximum number of search results to return.

SearchSource

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

SearchSource

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

SearchSource

The name of the source for display.

LocatorSearchSource

Specifies the fields returned with the search results.

SearchSource

Used as a hint for the source input text.

LocatorSearchSource

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

SearchSource

The popup template used to display search results.

SearchSource

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

SearchSource

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

SearchSource

The symbol used to display the result.

SearchSource

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

LocatorSearchSource

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

LocatorSearchSource

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

SearchSource

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

LocatorSearchSource

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

LocatorSearchSource

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

SearchSource

The set zoom scale for the resulting search result.

LocatorSearchSource

Property Details

apiKey

Property
apiKey String
Since: ArcGIS Maps SDK for JavaScript 4.19 LocatorSearchSource since 4.0, apiKey added at 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 searchWidget = new Search({
  view: view,
  includeDefaultSources: false,
  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
autoNavigate Boolean
Inherited from SearchSource

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

Default Value:true

categories

Property
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.

countryCode

Property
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.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.

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

defaultZoomScale

Property
defaultZoomScale Number
Since: ArcGIS Maps SDK for JavaScript 4.13 LocatorSearchSource since 4.0, defaultZoomScale added at 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
reactiveUtils.when(
  () => searchWidget.viewModel.state === "ready",
  () => {
    let firstSource = searchWidget.allSources.at(0);
    if (firstSource) {
      firstSource.defaultZoomScale = 100000;
    }
  }
);

filter

Property
filter Object
Since: ArcGIS Maps SDK for JavaScript 4.4 LocatorSearchSource since 4.0, filter added at 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 = [{
  url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
  placeholder: "Darwin",
  maxResults: 3,
  filter: searchExtent
}];

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

getResults

Inherited
Property
getResults GetResultsHandler
Inherited from SearchSource

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

getSuggestions

Inherited
Property
getSuggestions GetSuggestionsParameters
Inherited from SearchSource

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

localSearchDisabled

Property
localSearchDisabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.22 LocatorSearchSource since 4.0, localSearchDisabled added at 4.22.

This property controls prioritization of Search widget 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 or SceneView 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 or SceneView.

Default Value:false
Example
const searchWidget = new Search({
  view: view,
  includeDefaultSources: false,
  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
locationType String
Since: ArcGIS Maps SDK for JavaScript 4.12 LocatorSearchSource since 4.0, locationType added at 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
reactiveUtils.when(
  () => searchWidget.viewModel.state === "ready",
  () => {
    let firstSource = searchWidget.allSources.at(0);
    if (firstSource) {
      firstSource.locationType = "rooftop";
    }
  }
);

maxResults

Inherited
Property
maxResults Number
Inherited from SearchSource

Indicates the maximum number of search results to return.

Default Value:6

maxSuggestions

Inherited
Property
maxSuggestions Number
Inherited from SearchSource

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

Default Value:6

minSuggestCharacters

Inherited
Property
minSuggestCharacters Number
Inherited from SearchSource

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

Default Value:1

name

Property
name String

The name of the source for display.

outFields

Inherited
Property
outFields String[]
Inherited from SearchSource

Specifies the fields returned with the search results.

placeholder

Property
placeholder String

Used as a hint for the source input text.

popupEnabled

Inherited
Property
popupEnabled Boolean
Inherited from SearchSource

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

popupTemplate

Inherited
Property
popupTemplate PopupTemplate
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 popupTemplate configured on the layer.

prefix

Inherited
Property
prefix String
Inherited from SearchSource

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

resultGraphicEnabled

Inherited
Property
resultGraphicEnabled Boolean
Inherited from SearchSource

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

resultSymbol

Inherited
Property
resultSymbol Symbol
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
searchTemplate String

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

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

singleLineFieldName

Property
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

Inherited
Property
suffix String
Inherited from SearchSource

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

suggestionsEnabled

Property
suggestionsEnabled Boolean

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

Default Value:true

url

Property
url String
Since: ArcGIS Maps SDK for JavaScript 4.22 LocatorSearchSource since 4.0, url added at 4.22.

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

Example
const sources = [{
  url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
}];

const searchWidget = new Search({
  view: view,
  sources: sources  // autocasts as new LocatorSearchSource()
});

withinViewEnabled

Inherited
Property
withinViewEnabled Boolean
Inherited from SearchSource

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

Default Value:false

zoomScale

Property
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: [
    {
      url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer",
      name: "LocatorSearchSource",
      zoomScale: 500000
    }
  ]
});

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Creates a deep clone of this object.

LocatorSearchSource
*

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

LocatorSearchSource

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

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

LocatorSearchSource

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

clone

Method
clone(){LocatorSearchSource}

Creates a deep clone of this object.

Returns
Type Description
LocatorSearchSource A clone of the new LocatorSearchSource instance.

fromJSON

Method
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.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Method
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.