https://developers.google.com/places/web-service/details
I get CORS error. OK I`ve tried use jsonp in angular and get another error.
Uncaught SyntaxError: Unexpected token :
I think its because gmaps api doesn't support jsonp. Querying Google Places API using jQuery
But how to get place details from API via angular
?
code
const params = new URLSearchParams();
params.append('key', 'MYAPIKEY');
params.append('placeid', placeId);
params.append('callback', 'JSONP_CALLBACK');
const url = 'https://maps.googleapis.com/maps/api/place/details/json';
return this.jsonp.get(url, {search: params});
or
getPlaceDetails(placeId: string) {
const httpParams = new HttpParams()
.append('key', 'MYAPIKEY')
.append('placeid', placeId);
const url = 'https://maps.googleapis.com/maps/api/place/details/json';
return this.http.get<PlaceDetail>(url, {params: httpParams}).map(c => c.result);
}
second method works if I use cors chrome extension