Find

This sample demonstrates how to use find to search for records in a map service, then display the results in an HTML table.

Although find does not require you to display a map, it requires a URL to an ArcGIS Server map service. FindParameters restricts the search to only the areaname field of the Cities layer (index 0).

1
2
3
params = new FindParameters();
params.layerIds = [0];
params.searchFields = ["areaname"];

When you click the Find button, the function doFind reads the input box and uses it as the search text. The find is then executed:

1
2
params.searchText = document.getElementById("searchText").value;
find.find(findUrl, params).then(showResults).catch(rejectedPromise);

The results are returned as an array of FindResult objects. These are graphics, which have attributes that you can retrieve through syntax such as result.feature.attributes.AREANAME. After find completes, the callback function showResults() loops through these features and constructs an HTML table from their attributes.

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

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close