ecoLogic
ecoLogic

Reputation: 75

HERE MAPS: Autosuggest Places for Angular

I'm trying to implement Autosuggest Places from HERE Maps to the Angular project, but it seems like there is no option to use /autosuggest endpoint?

Is there any workaround to get autosuggested values with full location response? If I use "Suggest", then the response is just address name.

I've set up the project as described by Nic Raboy on https://developer.here.com/blog/display-here-maps-angular-web-application

For getting autosuggested values, I would love to use something like this ( that should make sense based on the documentation ):

declare let H;
...
private platform: any;

...

this.platform = new H.service.Platform({
      app_id: <app_id>,
      app_code: <app_code>
    });
...

const place = this.f.address.value;
const parameters = {
   at: '52.5113,13.3791',
   q: place
};

const places = this.platform.getPlacesService();
places.autosuggest(parameters, 
    result => {
      console.log(result);
    }, error => {
      reject(error);
    });

places.autosuggest does not exists, and based on the v3_3.0.mapsjs-service.js, places only support: "Suggest", "Explore", "Around", "Here", "Caetgories".

Upvotes: 1

Views: 972

Answers (1)

Michel
Michel

Reputation: 28349

The methods suggest, explore, and others from the Maps JavaScript API, are convenient wrappers around Places API REST endpoints.

You can get results from Places Autosuggest, by using the Angular HttpClient class and calling the Autosuggest API directly.

This will be something along the lines of:

this.http.get<AutosuggestResult>(
   'https://places.api.here.com/places/v1/autosuggest',
  { params }
)

Upvotes: 1

Related Questions