【发布时间】:2021-10-17 00:05:46
【问题描述】:
const response = await fetch(
//`https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=${textInput}&location=${latitude}%${longitude}&key=${apiKey}`,
//`https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=pizza%20near%20par&key=${apiKey}`,
`https://maps.googleapis.com/maps/api/place/autocomplete/json?input=amoeba&types=establishment&location=37.76999%2C-122.44696&radius=500&key=${apiKey}`,
{}
);
console.log("TEST: place response ", JSON.stringify(response));
我在网上找不到任何相关问题, 我尝试了几个直接从文档中的示例复制的不同端点,但都返回相同的响应:
{
"type":"default",
"status":200,
"ok":true,
"statusText":"",
"headers":{
"map":{
"server":"scaffolding on HTTPServer2",
"expires":"Sat, 16 Oct 2021 23:19:04 GMT",
"server-timing":"gfet4t7; dur=92",
"content-type":"application/json; charset=UTF-8",
"alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"",
"cache-control":"public, max-age=300",
"x-xss-protection":"0",
"content-encoding":"gzip",
"date":"Sat, 16 Oct 2021 23:14:04 GMT",
"x-frame-options":"SAMEORIGIN",
"content-length":"526",
"vary":"Accept-Language"
}
},
"url":"https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=pizza%20near%20par&key=MY_API_KEY",
"bodyUsed":false,
"_bodyInit":{
"_data":{
"size":6304,
"offset":0,
"blobId":"62109E2F-1D20-473B-94A5-2A3E7C664E9A",
"type":"application/json",
"name":"json",
"__collector":{
}
}
},
"_bodyBlob":{
"_data":{
"size":6304,
"offset":0,
"blobId":"62109E2F-1D20-473B-94A5-2A3E7C664E9A",
"type":"application/json",
"name":"json",
"__collector":{
}
}
}
}
我在我的谷歌开发者控制台中启用了 Place API。 多谢!
【问题讨论】:
标签: google-api google-places-api