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 geocoding package from ArcGIS REST JS to search for an address or a place, find candidate matches, and return complete addresses with a location by accessing the geocoding service.
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 service with ArcGIS REST JS, you typically perform the following steps:
- Reference the appropriate package.
- Set the API key to authenticate the request.
- Define parameters to pass to the service.
- Call the service and handle the results.
Example
In this example, you use the geocode
operation to convert the address text "1600 Pennsylvania Ave, 20500" into a location.
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { geocode } from "@esri/arcgis-rest-geocoding";
geocode({
address: "1600 Pennsylvania Ave",
postal: 20500,
countryCode: "USA",
authentication: ApiKeyManager.fromKey("YOUR_ACCESS_TOKEN");
})