@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
384 lines (382 loc) • 14.8 kB
TypeScript
import type SearchSource from "./SearchSource.js";
import type { LocationType } from "../../rest/types.js";
import type { SearchSourceProperties } from "./SearchSource.js";
import type { SearchFilter } from "./types.js";
export interface LocatorSearchSourceProperties extends SearchSourceProperties, Partial<Pick<LocatorSearchSource, "apiKey" | "categories" | "countryCode" | "defaultZoomScale" | "language" | "localSearchDisabled" | "locationType" | "name" | "searchTemplate" | "singleLineFieldName" | "url">> {
/**
* This property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent`
* properties. Setting a value here takes precedence over [withinViewEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#withinViewEnabled).
* Please see the object specification table below for details.
*
* @since 4.4
* @see [withinViewEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#withinViewEnabled)
* @example
* 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
* }];
* @example
* 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
* });
*/
filter?: SearchFilter | null;
/**
* Used as a hint for the source input text.
*
* @default ""
*/
placeholder?: string | null;
/**
* Indicates whether to display suggestions
* as the user enters input text.
*
* @default true
*/
suggestionsEnabled?: boolean | null;
/**
* The set zoom scale for the resulting search result.
* This scale is automatically honored.
*
* @example
* 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
* }];
* @example
* let searchWidget = new Search({
* view: view,
* sources: [
* {
* layer: featureLayer,
* searchFields: ["Name", "Team"],
* name: "LayerSearchSource",
* zoomScale: 500000
* }
* ]
* });
*/
zoomScale?: number | null;
}
/**
* The following properties define a [source](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/#sources) pointing to a
* [url](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#url) that represents a locator service, which may be used to geocode locations
* with a [Search widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/) or [Search component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-search/).
*
* @since 4.0
* @see [Search widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/) - _Deprecated since 4.33. Use the [Search component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-search/) instead._
* @see [Search component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-search/)
* @see [Sample - Search component with multiple sources](https://developers.arcgis.com/javascript/latest/sample-code/search-component-multisource/)
*/
export default class LocatorSearchSource extends SearchSource {
constructor(properties?: LocatorSearchSourceProperties);
/**
* An authorization string used to access a resource or service.
* [API keys](https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/) 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](https://developers.arcgis.com/javascript/latest/references/core/config/#Config-apiKey).
*
* @since 4.19
* @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"
* }];
*/
accessor apiKey: 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 [World Geocode Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm)
*/
accessor categories: 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 [World Geocode Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm)
*/
accessor countryCode: string | null | undefined;
/**
* Sets the scale of the [MapView.scale](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#scale) or [SceneView.scale](https://developers.arcgis.com/javascript/latest/references/core/views/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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#zoomScale) instead.
*
* @since 4.13
* @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;
* }
* }
* );
*/
accessor defaultZoomScale: number | null | undefined;
/**
* This property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent`
* properties. Setting a value here takes precedence over [withinViewEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#withinViewEnabled).
* Please see the object specification table below for details.
*
* @since 4.4
* @see [withinViewEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/#withinViewEnabled)
* @example
* 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
* }];
* @example
* 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
* });
*/
accessor filter: SearchFilter | null | undefined;
/**
* 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.
*
* @since 4.34
* @see [ArcGIS REST APIs | langCode](https://developers.arcgis.com/rest/geocode/reverse-geocode/#langcode)
* @see [ArcGIS REST APIs | Supported countries](https://developers.arcgis.com/rest/geocode/geocode-coverage/#level-1)
* @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",
* }
* ]
* });
*/
accessor language: string | null | undefined;
/**
* 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](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#scale)
* or [SceneView.scale](https://developers.arcgis.com/javascript/latest/references/core/views/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](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#scale) or
* [SceneView.scale](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#scale).
*
* @default false
* @since 4.22
* @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
* }];
*/
accessor localSearchDisabled: boolean;
/**
* Defines the type of location, either `street` or `rooftop`, of the point returned from the
* [World Geocoding Service](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm).
*
* @since 4.12
* @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";
* }
* }
* );
*/
accessor locationType: LocationType | null | undefined;
/**
* The name of the source for display.
*
* @default ""
*/
accessor name: string;
/**
* Used as a hint for the source input text.
*
* @default ""
*/
accessor placeholder: string | null | undefined;
/**
* A template string used to display multiple
* fields in a defined order when results are displayed.
*
* @default ""
* @example locatorLayerSource.searchTemplate = "{County}, {State}";
*/
accessor searchTemplate: 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`.
*/
accessor singleLineFieldName: string | null | undefined;
/**
* Indicates whether to display suggestions
* as the user enters input text.
*
* @default true
*/
accessor suggestionsEnabled: boolean | null | undefined;
/**
* URL to the ArcGIS Server REST resource that represents a locator service.
* This is **required**.
*
* @since 4.22
* @example
* const searchElem = document.querySelector("arcgis-search");
* await searchElem.componentOnReady();
* searchElem.sources = [{
* url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
* }];
*/
accessor url: string | null | undefined;
/**
* The set zoom scale for the resulting search result.
* This scale is automatically honored.
*
* @example
* 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
* }];
* @example
* let searchWidget = new Search({
* view: view,
* sources: [
* {
* layer: featureLayer,
* searchFields: ["Name", "Team"],
* name: "LayerSearchSource",
* zoomScale: 500000
* }
* ]
* });
*/
accessor zoomScale: number | null | undefined;
/**
* Creates a deep clone of this object.
*
* @returns A clone of the new [LocatorSearchSource](https://developers.arcgis.com/javascript/latest/references/core/widgets/Search/LocatorSearchSource/) instance.
*/
clone(): LocatorSearchSource;
}