在Google Places中,当编辑我的业务时,我可以在“基本信息”下添加“描述”。顺便说一下,要进行这样的编辑,请转到http://www.google.com/local/add/businessCenter,然后单击企业列表下的“编辑”。
当我向Places API查询我的业务的详细信息时,我没有看到这个“描述”:
url = "https://maps.googleapis.com/maps/api/place/details/json?key=#{key}&sensor=#{sensor}&reference=#{reference}"我查看了Place Details Results,但也没有看到"description“字段。
那么,如何通过Google API查询来获取位置/业务描述字段呢?
发布于 2013-09-21 13:51:43
问题是“如何获取描述”,但用户继续描述他们编辑自己业务的问题。
谷歌似乎没有将Place的描述存储在自己的Google Places DB中,而是从Freebase/Wikipedia的相关页面中摘录出来
编辑您的业务描述的答案是“您不能直接”或“创建或编辑您的维基百科/Freebase页面来间接添加/修改描述”。
继续阅读,寻找如何使用places-api“获取”业务描述的答案。此示例使用PHP。
维基百科的许多文章都没有指出lng/lat的关系,所以你不能用维基百科的APi进行近邻/名字搜索。
然而,FreeBase的大部分信息都是从维基百科上获得的,而且通常都有lat/lng的信息。
//Gather info from Google Places API
//$_GET['gID'] is the Reference for the Place you want info for.
$url = "https://maps.googleapis.com/maps/api/place/details/json?"
."reference=".$_GET['gID']
."&sensor=false"
."&key=YOUR KEY";
$results = ProcessCurl ($url);
$gPlace = json_decode($results);
//Gather info from FreeBase
$url = "https://www.googleapis.com/freebase/v1/search?"
."indent=true"
."&filter=%28all"
."+type%3Alocation"
."+name%3A%22". urlencode($gPlace->result->name) ."%22"
."%28within+radius%3A100ft"
."+lon%3A". $gPlace->result->geometry->location->lng
."+lat%3A". $gPlace->result->geometry->location->lat ."%29%29"
."&output=%28description%29";
$results = ProcessCurl ($url);
$FreeBase = json_decode($results);
//ensure we got results from FreeBase
//All we want from FreeBase is the Description
if ($FreeBase->status == "200 OK" && $FreeBase->hits > 0) {
$member = "/common/topic/description";
$Description = $FreeBase->result[0]->output->description->$member;
print_r ($Description[0]);此示例使用Google Place的名称和Lat/Lng,并在距其LAT/LNG 100英尺的范围内搜索FreeBase DB的“Locations”类型。
我确信代码可以做得更好,但到目前为止它工作得很好。
还有--值得注意的是--当你在谷歌上搜索一个“地点”时,会发现谷歌首先搜索FreeBase,然后再将结果与类似的谷歌地点结果进行匹配。这就是为什么当你在google上搜索一个地点时,右边的结果可能与Google Places结果的名称不同,并且有一个描述,但是如果你使用'near‘,你会注意到相同的地方现在没有描述。
例如,我在加拿大安大略省的伦敦市,我可以搜索“Fanshawe学院”,结果是“Fanshawe学院”,包括描述。然而,在地图小程序上,如果我在谷歌上搜索“伦敦附近的范肖学院”,指针就会指向一个名为“范肖学院-伦敦校区”的地方;搜索结果是“范肖学院-伦敦校区”,没有任何描述,信息也更少。
https://stackoverflow.com/questions/16526566
复制相似问题