geocode

Function
import { geocode } from '@esri/arcgis-rest-geocoding';
//
geocode("LAX")
  .then((response) => {
    response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: ...  }
  });
//
geocode({
  address: "1600 Pennsylvania Ave",
  postal: 20500,
  countryCode: "USA"
})
  .then((response) => {
    response.candidates[1].location; // => { x: -77.036533, y: 38.898719, spatialReference: ... }
  });

Used to determine the location of a single address or point of interest. See the REST Documentation for more information.

Parameters

Parameter Type Default Notes
address Required string | IGeocodeOptions

String representing the address or point of interest or RequestOptions to pass to the endpoint.

Returns

A Promise that will resolve with address candidates for the request. The spatial reference will be added to candidate locations and extents unless rawResponse: true was passed.

Promise<IGeocodeResponse>
Property Type Notes
candidates Array<{
address:
string
attributes:
object
extent:
IExtent
location:
IPoint
score:
number
}>
spatialReference ISpatialReference
geoJson Optional {
features:
Array<{
geometry:
object
properties:
any
type:
string
}>
type:
string
}

Function defined in packages/arcgis-rest-geocoding/src/geocode.ts:92