Autosuggest

autosuggest

Suggestions displayed as characters are added using a widget and the geocoding service.

What is autosuggest?

Autosuggest, also known as autocomplete, is the process of using incomplete text to search for place names and addresses. For example, you can search for "New Y", "Dodgers S", and "Cali" to get a list of suggested place names that match.

You can use autosuggest to build applications that:

  • Autocomplete addresses and places as you type.
  • Provide a list of suggestions for incomplete address and place names.
  • Refine place names and addresses to improve geocoding accuracy.

How autosuggest works

You can get address and place name suggestions by making an HTTP request to the geocoding service suggest operation or by using client APIs. Specify the address or place name text, and optionally, additional parameters to refine the search.

You can provide text for a partial place name or a partial address to get search results. Typically 2-3 characters are needed to start searching.

To refine the search and improve accuracy, you can provide additional information such as the location, search extent, category, and country code.

The geocoding service parses the text and uses all of the parameters provided to return a set of suggestions. Each suggestion contains text (address or place name), isCollection (single distinct place or multiple with the same name or category), and magicKey (search identifier) properties.

URL request

Use dark colors for code blocksCopy
1
https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?text={partialText}&f=json&token=<ACCESS_TOKEN>

Required parameters

NameDescriptionExamples
fThe format of the data returned.f=json f=pjson
tokenAn API key or OAuth 2.0 access token. Learn how to get an access token in Security and authentication.token=<YOUR_API_KEY>
token=<ACCESS_TOKEN>

Key parameters

NameDescriptionExamples
textThe partial address or place name. Different formats are supported.text=starbutext=100, main sttext=New Y

Additional parameters: Refine the search by using parameters such as location, searchExtent, category, and countryCode.

Code examples

Get suggestions for a string

This example finds suggestions for the string New Y. To find the actual address and location for a suggestion, you have to pass each text and magicKey value to the geocoding service. Most APIs provide a LocatorTask to access the service.

Steps

  1. Reference the geocoding service.

  2. Set the text to search for.

  3. Set the API key.

The response is a set of suggestions (max of 5) containing the text and magicKey properties. Use these properties to search for the complete address with a location.

Get suggestions for a string

Find suggestions for the string New Y.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)ArcGIS API for PythonArcGIS Maps SDK for SwiftArcGIS REST JSEsri LeafletMapLibre GL JSOpenLayersCesiumJS
Expand
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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
          geocodingServiceUrl = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";

          const params = {
            text: "New Y", // Suggestion text
          };

          locator.suggestLocations(geocodingServiceUrl, params).then((response) => {
            // Show a list of the suggestions
            response.forEach((suggestion) => {
              showSuggestion(suggestion.text, suggestion.magicKey);
            });
            // When a suggestion is selected, geocode to find its location
            select.addEventListener("calciteSelectChange", (event) => {
              const text = event.target.innerHTML;
              const magicKey = event.target.value;
              geocodeSuggestion(text, magicKey);
            });
          });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest \
-d 'f=pjson' \
-d 'text=New Y' \
-d 'token=<ACCESS_TOKEN>'

Tutorials

Services

Geocoding service

Search for an address, reverse geocode, and batch geocode.

API support

GeocodingReverse GeocodingBatch GeocodingPlace/POI SearchAutosuggestUI Component
ArcGIS Maps SDK for JavaScript
ArcGIS Maps SDK for .NET1
ArcGIS Maps SDK for Kotlin1
ArcGIS Maps SDK for Swift1
ArcGIS Maps SDK for Java1
ArcGIS Maps SDK for Qt1
ArcGIS API for Python
ArcGIS REST JS
Esri Leaflet2
MapLibre GL JS22222
OpenLayers22222
Full supportPartial supportNo support
  • 1. No runtime API. Access via HTTP request.
  • 2. Access via ArcGIS REST JS.

Tools

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