You will learn: how to find addresses and places with the ArcGIS World Geocoding Service.
The ArcGIS World Geocoding Service can find addresses, places, convert addresses to coordinates, and perform batch geocoding. If you would like to create an application that can find the coordinates (latitude and longitude) for one or more addresses, you can use the ArcGIS REST API to call the findAddressCandidates
operation. All you need to do is pass in an address e.g. "380 New York St., Redlands, CA" and the service will return a set of candidates. Once you have candidates, you can add them to a map, create a route, or integrate them further into your application. You can also geocode many addresses at once with the geocodeAddresses
operation. To learn more about the capabilities of the geocoding service, please visit the documentation.
In this tutorial you will use the ArcGIS REST API to access the ArcGIS World Geocoding Service to find the coordinates for an address.
Install Postman to execute HTTP requests. Go to this tutorial if you need an access token.
Open Postman and click [+] in the tab bar to create a new request.
In the new tab, set the following:
GET
https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates
Click on Params next to the URL and the following:
f
: json
singleLine
: 4730 Crystal Springs Dr, Los Angeles, CA 90027
outFields
: Match_addr,Addr_type
Click Send to run the request.
In the response window, click Pretty > JSON and it should look something like this:
{
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"candidates": [
{
"address": "4730 Crystal Springs Dr, Los Angeles, California, 90027",
"location": {
"x": -118.27393677823306,
"y": 34.123473000000004
},
"score": 100,
"attributes": {
"Match_addr": "4730 Crystal Springs Dr, Los Angeles, California, 90027",
"Addr_type": "PointAddress"
},
"extent": {
"xmin": -118.27486,
"ymin": 34.122473000000006,
"xmax": -118.27285999999999,
"ymax": 34.124473000000002
}
},
{
"address": "4730 Crystal Springs Rd, Los Angeles, California, 90027",
"location": {
"x": -118.29234632205821,
"y": 34.140621986664307
},
"score": 98.040000000000006,
"attributes": {
"Match_addr": "4730 Crystal Springs Rd, Los Angeles, California, 90027",
"Addr_type": "StreetAddress"
},
"extent": {
"xmin": -118.29334632205821,
"ymin": 34.139621986664309,
"xmax": -118.2913463220582,
"ymax": 34.141621986664305
}
}
]
}
Go to the top of the response and find the spatialReference
and candidates
properties. The spatialReference
is 4326 and tells you that the coordinates given in candidates
will be latitude/longitude coordinates (y/x). This is the default spatial reference.
{
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
...
Find the candidates
property. This is an array of possible matches for the address. Each match consists of:
address
: The address of this match.location
: The x/y coordinates of this match. Note that x is longitude and y is latitude.score
: The confidence level of the geocoder in this match, on a scale of 1-100.attributes
: Any additional fields requested by the outFields
parameter.extent
: a rectangular bounding box around the location
given as a pair of x/y coordinates. "candidates": [
{
"address": "4730 Crystal Springs Dr, Los Angeles, California, 90027",
"location": {
"x": -118.27393677823306,
"y": 34.123473000000004
},
"score": 100,
"attributes": {
"Match_addr": "4730 Crystal Springs Dr, Los Angeles, California, 90027",
"Addr_type": "PointAddress"
},
"extent": {
"xmin": -118.27486,
"ymin": 34.122473000000006,
"xmax": -118.27285999999999,
"ymax": 34.124473000000002
}
},
...
You have successfully found a set of candidates with coordinates for an address.
You can use the Esri World Geocoding Service to build an auto-completing, suggestion-based UX by adding a special parameter called magicKey
to findAddressCandidates
instead of an address. To obtain a value for magicKey
, refer to the documentation for the suggest endpoint.
If you need to geocode many addresses in bulk, you can use the geocode addresses endpoint.
findAddressCandidates
can also return the coordinates of intersections if the address is in the proper format. For more information, see searching for intersections and try changing the value of singleLine
to "Grasswood Ave & Cliffside Dr, Malibu, CA, 90265, USA"