Learn how to find an address or

Geocoding is the process of converting address or Search component to access the Geocoding service and perform interactive searches.
In this tutorial, you will use the Search component to search for addresses and
Prerequisites
Steps
Create a new pen
- To get started, either complete the Display a map tutorial or
.
Get an access token
You need an
- Go to the Create an API key tutorial and create an
API key with the followingprivilege(s) :
- Privileges
- Location services > Basemaps
- Location services > Geocoding
- Privileges
- In CodePen, set the
apiKeyproperty on the globalesriConfigvariable to your access token.var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};
To learn about other ways to get an access token, go to Types of authentication.
Update the map
A streets basemap property to use the arcgis/navigation basemap layer and change the position of the map to center on Seattle.
- Update the
basemapattribute fromarcgis/topographictoarcgis/navigation. Then update thecenterattribute to[-122.3321, 47.6062]and set thezoomattribute to12to center on Seattle. .29 collapsed lines<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>ArcGIS Maps SDK for JavaScript Tutorials: Search for an address</title><style>html,body {height: 100%;margin: 0;}</style><script>var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};</script><!-- Load the ArcGIS Maps SDK for JavaScript from CDN --><script type="module" src="https://js.arcgis.com/5.0/"></script></head><body><arcgis-map basemap="arcgis/navigation" center="-122.3321,47.6062" zoom="12"><arcgis-zoom slot="top-left"></arcgis-zoom></arcgis-map>5 collapsed lines</body></html>
Add Search component
The Search component is a control that allows you to interactively search for addresses and places. It provides suggestions as you type and allows you to select a result. When you select a result, it zooms to a location and displays a locator and sources that accesses the
-
Inside the
<arcgis-map>component, add the<arcgis-search>component and specify its slot.29 collapsed lines<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>ArcGIS Maps SDK for JavaScript Tutorials: Search for an address</title><style>html,body {height: 100%;margin: 0;}</style><script>var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};</script><!-- Load the ArcGIS Maps SDK for JavaScript from CDN --><script type="module" src="https://js.arcgis.com/5.0/"></script></head><body><arcgis-map basemap="arcgis/navigation" center="-122.3321,47.6062" zoom="12"><arcgis-zoom slot="top-left"></arcgis-zoom><arcgis-search slot="top-right"></arcgis-search></arcgis-map>5 collapsed lines</body></html>
Run the app
In CodePen, run your code to display the map.
Try searching for the following locations: - Seattle - Space Needle - Hollywood Blvd - 34.13419, -118.29636
The map should display a Search component that allows you to interactively search for addresses and
What’s next?
Learn how to use additional SDK features and ArcGIS services in these tutorials: