Retrieve Location Details for a Suggestion
After the user types a few characters, request a list of suggestions from the Geocoder Autocomplete API. Show the suggestions to the user. After the user selects a suggestion, retrieve the detailed location information corresponding to the suggestion using the Geocoder API.
Request
Request a list of address suggestions for the search text Pariser 1 Berl
:
http://autocomplete.geocoder.cit.api.here.com/6.2/suggest.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&query=Pariser+1+Berl
&beginHighlight=<b>
&endHighlight=</b>
Response
The response from the Geocoder Autocomplete API contains a number of suggestions. Each of them represents a location defined through a set of attributes, but these do not provide detailed location information such as geographic coordinates.
{
"suggestions": [
{
"label": "Deutschland, Berlin, Berlin, 10117, Berlin, Pariser Platz 1",
"language": "de",
"countryCode": "DEU",
"locationId": "NT_5mGkj3z90Fbj4abzMbUE4C_xA",
"address": { ... },
"matchLevel": "houseNumber"},
... ]
}
Geocoder Request to retrieve the Location Details
After the user has selected a suggestion, you can retrieve the location details such as the geographic coordinates via the HERE Geocoder API, using look-up by locationId
.
http://geocoder.cit.api.here.com/6.2/geocode.json
?locationid=NT_5mGkj3z90Fbj4abzMbUE4C_xA
&jsonattributes=1
&gen=9
&app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
Geocoder Response
{
"response":
...
"view": [{
"result": [{
"matchLevel": "houseNumber",
"matchType": "pointAddress",
"location": {
"locationId": "NT_5mGkj3z90Fbj4abzMbUE4C_xA",
"locationType": "point",
"displayPosition": {
"latitude": 52.51588,
"longitude": 13.37804 },
"navigationPosition": [{
"latitude": 52.51591,
"longitude": 13.37833 }],
"mapView": {
"topLeft": {
"latitude": 52.5248732,
"longitude": 13.3632617 },
"bottomRight": {
"latitude": 52.5068868,
"longitude": 13.3928183 }},
"address": {
"label": "Pariser Platz 1, 10117 Berlin, Deutschland",
"country": "DEU",
"state": "Berlin",
"county": "Berlin",
"city": "Berlin",
"district": "Mitte",
"street": "Pariser Platz",
"houseNumber": "1",
"postalCode": "10117",
"additionalData": [{
"value": "Deutschland",
"key": "CountryName" },
{
"value": "Berlin",
"key": "StateName" },
{
"value": "Berlin",
"key": "CountyName" }]}}}],
"viewId": 0 }]
}
}