geocode
Functiongeocode(address: string | IGeocodeOptions): Promise<IGeocodeResponse>
Used to determine the location of a single address or point of interest. See the REST Documentation for more information.
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: ... }
});
Parameters
Parameter | Type | Notes |
---|---|---|
address | string | IGeocodeOptions | String representing the address or point of interest or RequestOptions to pass to the endpoint. |
Returns
Promise<IGeocodeResponse>
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.