【发布时间】:2020-07-22 12:51:17
【问题描述】:
export class AddressSuggestionsService {
private addressSuggestionsUrl =
'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?f=json&singleLine=';
constructor(private httpClient: HttpClient) {}
getAddressSuggestions(term: string): Observable<any> {
return this.httpClient
.get(
`${this.addressSuggestionsUrl}${term}&outfields=Match_addr,Addr_type=PointAddress`
)
.pipe(
tap((data) => console.log('All: ' + JSON.stringify(data))),
catchError(this.handleError)
);
}
}
我正在为 Angular 中的地址建议构建一个自动完成的搜索栏。地址建议来自 URL 中的第三方提供商。我无法从 Observable 响应中提取某个键。该键名为Candidates。是否可以从服务中的可观察响应中仅提取密钥? github repo
【问题讨论】:
标签: angular service autocomplete rxjs esri