Search for an address

Learn how to find an address or with a Search component and the .

Search for an address

Geocoding is the process of converting address or text into a . The can search for an address or a place and perform . Use the 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

  1. To get started, either complete the Display a map tutorial or .

Get an access token

You need an with the correct privileges to access the used in this tutorial.

  1. Go to the Create an API key tutorial and create an with the following :
    • Privileges
      • Location services > Basemaps
      • Location services > Geocoding
  2. In CodePen, set esriConfig.apiKey to your access token.
    1
    2
    3
    4
    5
    6
    7
    8
    9
      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 is typically used in geocoding applications. Update the basemap property to use the arcgis/navigation basemap layer and change the position of the map to center on Seattle.

  1. Update the basemap attribute from arcgis/topographic to arcgis/navigation. Then update the center attribute to [-122.3321, 47.6062] and set the zoom attribute to 12 to center on Seattle. .
    Expand
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
        <arcgis-map basemap="arcgis/navigation" center="-122.3321,47.6062" zoom="12">
    
          <arcgis-zoom position="top-left"></arcgis-zoom>
    
        </arcgis-map>
    
    Expand

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 with the address information. By default, the component uses a locator and source that accesses the .

  1. Inside the <arcgis-map> component, add the <arcgis-search> component and specify its position.

    Expand
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
        <arcgis-map basemap="arcgis/navigation" center="-122.3321,47.6062" zoom="12">
    
          <arcgis-zoom position="top-left"></arcgis-zoom>
    
          <arcgis-search position="top-right"></arcgis-search>
    
        </arcgis-map>
    
    Expand

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 API features and ArcGIS services in these tutorials:

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