如何通过Google Places API获取商家"说明"?

use*_*833 9 google-maps google-places-api

在Google商家信息中,在编辑我的商家时,我可以在"基本信息"下添加"说明".顺便说一下,要进行此类修改,请转到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}"
Run Code Online (Sandbox Code Playgroud)

我查看了地方详细信息结果,也没有在那里看到"描述"字段.

那么如何通过Google API查询获取地方/商家说明字段?

The*_*son -2

问题询问“如何获取描述”,但用户继续描述编辑自己业务的问题。

看来 Google 并未将地点的描述存储在其自己的 Google Places DB 中,而是提供了相关 Freebase/Wikipedia 页面的摘录

编辑业务描述的答案是“您不能直接”或“创建或编辑您的 Wikipedia/Freebase 页面以间接添加/修改描述”

继续阅读有关如何使用places-api“获取”业务描述的答案。本示例使用 PHP。

许多维基百科文章没有指明经纬度坐标,因此您无法使用维基百科 APi 进行邻近/名称搜索。

然而,FreeBase 从维基百科获取大部分信息,并且通常有纬度/经度信息。

//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]);
Run Code Online (Sandbox Code Playgroud)

此示例使用 Google Place 的 NAME 和 LAT/LNG,并在其 Lat/Lng 100 英尺范围内搜索 FreeBase DB 的“位置”类型以查找该名称。

我确信代码可以做得更好,但到目前为止它运行得很好。

另外 - 值得注意的是 - 当您在 google 上搜索“地点”时,Google 会首先搜索 FreeBase,然后将该结果与类似的 Google 地点结果进行匹配。这就是为什么当您在 google 上搜索某个地点时,右侧的结果可能与 Google 地方信息结果的名称不同,并且有描述,但如果您使用“附近”,您会发现同一个地点现在没有描述。

例如,我在加拿大安大略省伦敦,我可以搜索“Fanshawe College”,结果是“Fanshawe College”,包括说明。但是在地图小程序上,指针指向一个名为“Fanshawe College - London Campus”的 Google Place ”如果我搜索“伦敦附近的范莎学院”,它指定我正在寻找一个地方;结果我得到了“范莎学院 - 伦敦校区”,没有描述,信息也很少。