我已经使用Google Places API添加了一些地方,然后搜索了他们,但我没有收到任何回复。 Google Places API文档指出,您自己添加的任何地方都可以立即提供给您自己的应用。看不到我添加的地方 - Google Places API
代码用于添加的地方:
$content = '{
"location": {
"lat": 55.9924222,
"lng": -4.5767703
},
"accuracy": 50,
"name": "MYPLACE",
"types": ["other"],
"website": "http://example.com",
"language": "en-GB"
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/place/add/json?key=MYKEY');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
$json_response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status != 201) {
die("response $json_response");
};
curl_close($curl);
$response = json_decode($json_response);
JSON响应:
{
"id":"f9f16c68e531d8fc583e9d6b321f91d3f4aee41b",
"place_id":"qgYvCi0wMDAwMDA2NTdhZjZiZTc5OjQ4ODg1MzIzOTc1OmZmOTA3OTI1MWEwOTdlYjI",
"reference":"CkQxAAAAXR8NXJss0Mkw79jPrfLSDfDV8v9n94HmuZsN5pPdvSp5D8gLlBlVvXdTHqJlAq6larv-asoMF22gc6vonSVM8xIQtYSx9WMivS9eI6MsrQuiMhoUtlAGv0nDCEAF-5lphcVBbO4CI-U",
"scope":"APP",
"status":"OK"
}
然后我搜索使用:
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=55.9859890,-4.5723500&radius=5000&type=other&keyword=getfed&key=MYKEY
和响应:
{
"html_attributions": [],
"results": [],
"status": "ZERO_RESULTS"
}
任何人都可以告诉我有什么问题吗?
嗨,感谢您的回复,但我认为您还没有理解文档。您粘贴的摘录显示:“当您添加地点时,新地点可立即在您的应用程序启动的附近搜索中提供。”您用粗体突出显示的部分是指普通用户在Google地图中出现的地方。我试图通过我自己的应用程序访问该地点,应该能够在添加后立即看到该地点。 –
从常见问题解答页面:“我如何创建自定义地点? 如果您想要添加可立即使用的地点,您可以执行地方添加请求,以便您的应用程序即时访问新添加的地点通过您的Google API控制台密钥。“ –