You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
front/src/app/services/auto-complete/auto-complete.service.ts

47 lines
1.0 KiB

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class AutocompleteService {
private apiUrl = 'https://nominatim.openstreetmap.org';
constructor(private http: HttpClient) {}
getAddressSuggestions(query: string): Observable<any> {
return this.http.get(this.apiUrl + '/search', {
params: {
q: query,
format: 'json',
addressdetails: '1',
limit: '5',
},
});
}
getAdressCoordinates(query: string): Observable<any> {
return this.http.get(this.apiUrl + '/search', {
params: {
q: query,
format: 'json',
addressdetails: '1',
limit: '1',
},
});
}
getAddressFromCoordinates(lat: number, lon: number): Observable<any> {
return this.http.get(this.apiUrl + '/reverse', {
params: {
lat: lat.toString(),
lon: lon.toString(),
format: 'json',
addressdetails: '1',
},
});
}
}