Introduction to geocoding

Geocoding, also known as address search, is the process of converting text for an address or place to a complete address with a location. You can use the to search for an address or a place, find candidate matches, and return complete addresses with a location.

With the service, you can build applications to:

  • Find the location of an address.
  • Convert address text to a complete address.
  • Provide a list of address candidates for an incomplete address.

How to access the geocoding service

To access the geocoding service with Esri Leaflet, you can use the geocoder plugin, which contains multiple classes and a UI control.

The operations you can perform include:

The typical steps to access the geocoding service with Esri Leaflet are to:

  1. Reference the Esri Leaflet and geocoder plugins.
  2. Define the parameters and set your API key.
  3. Call the service.

Examples

Find place addresses

In this example, you use the L.esri.Geocoding.geocode operation to find hotels near a location.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script src="https://unpkg.com/esri-leaflet@3.0.14/dist/esri-leaflet.js"></script>

<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@3.1.4/dist/esri-leaflet-geocoder.js" crossorigin="">

<script>
  L.esri.Geocoding
    .geocode({
      apikey: accessToken
    })
    .category("Hotel")
    .nearby(map.getCenter(), 10)
    .run(function (error, response) {
      if (error) {
        return;
      }
    })
</script>

Autosuggest places (UI control)

In this example, you use the geosearch control for an added UI element and autosuggest functionality. It uses the arcgisOnlineProvider to make a call to the geocoding service. However, you can specify other providers such as a feature layer or an ArcGIS Server geocode service to get results for text matches.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<script src="https://unpkg.com/esri-leaflet@3.0.14/dist/esri-leaflet.js"></script>

<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@3.1.4/dist/esri-leaflet-geocoder.css">

<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@3.1.4/dist/esri-leaflet-geocoder.js">
<script>
  const searchControl = L.esri.Geocoding.geosearch({
    position: "topright",
    placeholder: "Type in an address or place e.g. 1 York St",
    useMapBounds: false,
    providers: [L.esri.Geocoding.arcgisOnlineProvider({
      apikey: accessToken,
      nearby: {
        lat: -33.8688,
        lng: 151.2093
      },
    })]
  }).addTo(map);
</script>

Tutorials

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

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