Skip to content

Commit

Permalink
feat: replace geocode by autosuggest api for better match results (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
teriblus authored Oct 3, 2022
1 parent fcd403a commit 7a87adc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/providers/hereProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ export default class HereProvider extends AbstractProvider<
RequestResult,
RawResult
> {
searchUrl = 'https://geocode.search.hereapi.com/v1/geocode';
searchUrl = 'https://geocode.search.hereapi.com/v1/autosuggest';

endpoint({ query }: EndpointArgument): string {
const params = typeof query === 'string' ? { q: query } : query;
return this.getUrl(this.searchUrl, params);
}

parse(response: ParseArgument<RequestResult>): SearchResult<RawResult>[] {
return response.data.items.map((r) => ({
x: r.position.lng,
y: r.position.lat,
label: r.address.label,
bounds: null,
raw: r,
}));
return response.data.items
.filter((r) => r.position !== undefined)
.map((r) => ({
x: r.position.lng,
y: r.position.lat,
label: r.address.label,
bounds: null,
raw: r,
}));
}
}

0 comments on commit 7a87adc

Please sign in to comment.