Get suggestions for a place using an incomplete location query
This tutorial demonstrates how to search for a place using an incomplete location query.
Procedure
A user of an application using /autosuggest
is at a location in Berlin and intends to search the new airport named Berlin Brandenburg Willy Brandt through a query "berlin brandenburg". The application starts to emit autosuggest queries starting with the 3rd key-stoke. The 8th autosuggest query appears as follows:
GET https://autosuggest.search.hereapi.com/v1/
autosuggest
?at=52.5199813,13.3985138
&lang=en
&q=berlin+bran
&apiKey={YOUR_API_KEY}
The following parameters are used:
- at - Specify the center of the search context expressed as coordinates.
- lang - Select the language to be used for result rendering from a list of BCP 47 compliant language codes.
- q - Enter a free-text query.
- apiKey - Your API key.
The result lists detailed information about the related location objects:
{
"items": [
{
"title": "Brandenburg Gate",
"id": "here:pds:place:276u33db-8ee2e0de906e459cbade0593986debe9",
"resultType": "place",
"address": { "label": "Brandenburg Gate, Pariser Platz 1, 10117 Berlin, Germany" },
"position": { "lat": 52.51628, "lng": 13.37771 },
"access": [{ "lat": 52.5163, "lng": 13.37799 }],
"distance": 1466,
"categories": [{ "id": "300-3000-0025", "name": "Historical Monument", "primary": true }, { "id": "700-7460-0115", "name": "Tourist Information" }],
"references": [{ "supplier": { "id": "core" }, "id": "800842663" }, { "supplier": { "id": "core" }, "id": "935939740" }],
"highlights": { "title": [ ], "address": { "label": [ ] } }
},
{
"title": "Berlin Brandenburg Airport Willy Brandt",
"id": "here:pds:place:276u339g-0dd32a93728c47c3b35985e550f30a70",
"resultType": "place",
"address": { "label": "Berlin Brandenburg Airport Willy Brandt, Melli-Beese-Ring 1, 12529 Schönefeld, Germany" },
"position": { "lat": 52.36395, "lng": 13.50864 },
"access": [{ "lat": 52.36447, "lng": 13.51003 }],
"distance": 18887,
"categories": [{ "id": "400-4000-4581", "name": "Airport", "primary": true }],
"references": [{ "supplier": { "id": "core" }, "id": "1098368287" }, { "supplier": { "id": "yelp" }, "id": "L4LMcEkbutFG3bz-1i-keg" }],
"highlights": { "title": [ ], "address": { "label": [ ] } }
},
{
"title": "Gesundbrunnen Center",
"id": "here:pds:place:276u33db-84435950c4084967be9ccca7c6603d4e",
"resultType": "place",
"address": { "label": "Gesundbrunnen Center, Badstraße 4, 13357 Berlin, Germany" },
"position": { "lat": 52.54971, "lng": 13.38749 },
"access": [{ "lat": 52.54965, "lng": 13.3874 }],
"distance": 3389,
"categories": [
{ "id": "600-6100-0062", "name": "Shopping Mall", "primary": true },
...
],
"chains": [{ "id": "6825" }],
"references": [
{ "supplier": { "id": "core" }, "id": "50669554" },
{ "supplier": { "id": "tripadvisor" }, "id": "3166269" },
{ "supplier": { "id": "yelp" }, "id": "6SvL6NOKrknf9aTGK6f2Xw" }
],
"highlights": { "title": [ ], "address": { "label": [ ] } }
}
],
"queryTerms": [ ]
}
For more information about /autosuggest
parameters, see: API Reference.