Limit results using a spatial reference

This tutorial demonstrates how to use a spatial reference.

Procedure

Customer applications can use at to specify the center of the search context expressed as coordinates.

For example, one highly relevant result for a global query Paris would be the capital of France. But the end-users located in, for example, Berlin may be more interested to see street results around them, with street names starting from Paris.

Formulate the query like this:

GET https://autocomplete.search.hereapi.com/v1/
    autocomplete
    ?q=Paris
    &at=52.5249445%2C13.3689829
    &limit=2
    &apiKey={YOUR_API_KEY}

Note

This request uses API key authentication. For more information about authentication options on the HERE platform, see the Identity & Access Management Guide.

Note this query includes the parameter limit=2 to limit the number of the suggestions. The default limit for /autocomplete is 5. The maximum value for the limit parameter supported by /autocomplete is 20.

The response includes address suggestions for addresses around the specified position in Berlin that contain token Paris in this case in the street name:

{
  "items": [
    {
      "title": "Deutschland, Berlin, Pariser Platz",
      "id": "here:af:street:blZMmLnwtsYaXawaeHWfzC",
      "language": "de",
      "resultType": "street",
      "address": {
        "label": "Pariser Platz, 10117 Berlin, Deutschland",
        "countryCode": "DEU",
        "countryName": "Deutschland",
        "stateCode": "BE",
        "state": "Berlin",
        "countyCode": "B",
        "county": "Berlin",
        "city": "Berlin",
        "street": "Pariser Platz",
        "postalCode": "10117"
      },
      "distance": 1140,
      "highlights": {
        "title": [
          {
            "start": 21,
            "end": 26
          }
        ],
        "address": {
          "label": [
            {
              "start": 0,
              "end": 5
            }
          ],
          "street": [
            {
              "start": 0,
              "end": 5
            }
          ]
        }
      }
    },
    {
      "title": "Deutschland, Berlin, Straße der Pariser Kommune",
      "id": "here:af:street:AfkQXa0XADEPA-WZxLPzmB",
      "language": "de",
      "resultType": "street",
      "address": {
        "label": "Straße der Pariser Kommune, 10243 Berlin, Deutschland",
        "countryCode": "DEU",
        "countryName": "Deutschland",
        "stateCode": "BE",
        "state": "Berlin",
        "countyCode": "B",
        "county": "Berlin",
        "city": "Berlin",
        "district": "Friedrichshain",
        "street": "Straße der Pariser Kommune",
        "postalCode": "10243"
      },
      "distance": 4806,
      "highlights": {
        "title": [
          {
            "start": 32,
            "end": 37
          }
        ],
        "address": {
          "label": [
            {
              "start": 11,
              "end": 16
            }
          ],
          "street": [
            {
              "start": 11,
              "end": 16
            }
          ]
        }
      }
    }
  ]
}

The response for each item in this case contains the field distance, which is the distance in meters from the at position to this result.

Additional information

For more information about/autocomplete parameters, see: API Reference.

results matching ""

    No results matching ""