0

Is there an easy way to obtain the geolocation data of an autocomplete reply?
Currently only text is returned in a query. How would one read the GPS coordinates for an entry?

https://autocomplete.search.hereapi.com/v1/autocomplete?apiKey=xxx&q=k%C3%B6ln%20&in=countryCode:DEU&lang=de&limit=20&resultType=city,postalCode


 {
      "title": "Deutschland, Köln, Anschlussstelle Köln-Messe",
      "id": "here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD",
      "resultType": "street",
      "address": {
        "label": "Anschlussstelle Köln-Messe, 50679 Köln, Deutschland",
        "countryCode": "DEU",
        "countryName": "Deutschland",
        "stateCode": "NW",
        "state": "Nordrhein-Westfalen",
        "countyCode": "K",
        "county": "Köln",
        "city": "Köln",
        "street": "Anschlussstelle Köln-Messe",
        "postalCode": "50679"
      },
      "highlights": {
        "title": [
          {
            "start": 35,
            "end": 39
          }
        ],
        "address": {
          "label": [
            {
              "start": 16,
              "end": 20
            }
          ],
          "street": [
            {
              "start": 16,
              "end": 20
            }
          ]
        }
      }
    },
Nimantha
  • 6,405
  • 6
  • 28
  • 69
OGi
  • 113
  • 1
  • 7

1 Answers1

0

The idea of autocomplete is to provide key-by-key input completion for the end user. We believe the end user can decide based on the text response and does not need to show the position on the map. Only for the result that the user clicks on a lookup needs to be requested from the application which then shows the complete address including position.

So to get the geolocation, you need to use lookup endpoint while the user clicks, e.g: https://lookup.search.hereapi.com/v1/lookup?id=here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD&apiKey={{YOUR_API_KEY}}

In addition, you can evalaute the autosuggestion endpoint (which contains the position info) and see if it can meet your requirement: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html