Skip to content

Geocoding is the process of converting text to a complete address with a location.

You can use the arcgis-rest-geocoding package to access the ArcGIS Geocoding service.

Steps
  1. Install and reference the arcgis-rest-geocoding and arcgis-rest-request packages.
  2. Set an access token to authenticate the request.
  3. Define parameters to pass to the service.
  4. Call the service and handle the results.

Address geocoding

Address geocoding, also known as forward geocoding, allows you to search for addresses or places. In ArcGIS, this is referred to as finding address candidates.

Search for an address

Learn how to find address candidates with the geocode method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { geocode } from "@esri/arcgis-rest-geocoding";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

geocode({
  address: "1600 Pennsylvania Ave",
  postal: 20500,
  countryCode: "USA",
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Autosuggest

Autosuggest can help find address candidates with partial text input when building interactive geocoding controls.

Search with autosuggest

Learn how to use autosuggest candidates to find addresses with the suggest method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { suggest } from "@esri/arcgis-rest-geocoding";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

suggest("200 R", {
  authentication,
  params: {
    location: {
      x: -123.102,
      y: 49.234,
      spatialReference: { wkid: 4326 }
    },
    maxSuggestions: 5
  }
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Place geocoding

Place geocoding is the process of searching for addresses for businesses, administrative locations, and geographic features. You can search for the name of a place and/or provide categories to filter the results.

Find place addresses

Search for coffee shops near a given location using the geocode method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { geocode } from "@esri/arcgis-rest-geocoding";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

geocode({
  params: {
    category: "Coffee shop",
    location: "144.9850916862488,-37.798297645411",
    maxLocations: 20
  },
  outFields: "*",
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Reverse geocoding

Reverse geocoding allows you to convert a location into a complete address. You can also use it to find the nearest address to your current location or show the closest address when you tap the map.

Reverse geocode

Learn how to reverse geocode with the reverseGeocode method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { reverseGeocode } from "@esri/arcgis-rest-geocoding";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

reverseGeocode({
  location: [-79.3871, 43.6426], // [lon, lat]
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

More resources

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