2013-05-13 86 views
5

在Google商家信息中,編輯我的商家時,我可以在「基本信息」下添加「說明」。順便說一下,要做這樣的編輯,請轉到http://www.google.com/local/add/businessCenter,然後點擊商家信息下的「修改」。如何通過Google Places API獲取商家「描述」?

當我查詢API的地方爲自己的公司的細節,我沒有看到這個「說明」:

url = "https://maps.googleapis.com/maps/api/place/details/json?key=#{key}&sensor=#{sensor}&reference=#{reference}" 

我看着Place Details Results,也沒有看到「描述」字段有。

那麼,如何通過Google API查詢獲取地點/業務描述字段?

+0

有沒有人想過這一個? – rebelliard 2017-03-29 14:03:03

+0

我沒有。如果你弄明白了,請寫一個答案。 – user664833 2017-04-01 21:05:10

回答

-1

該問題詢問「如何獲取描述」,但用戶繼續描述他們編輯自己業務的問題。

看來,谷歌不儲存地點的描述在它自己的谷歌的地方DB而是給摘錄

有關的遊離鹼/維基百科頁面

答案編輯業務描述爲「你不能直接」或「創建或編輯您的Wikipedia/Freebase頁面以間接添加/修改說明「

繼續閱讀以獲取有關如何使用places-api」獲取「業務描述的答案。這個例子使用PHP。

許多維基百科文章並未指出lng/lat協作組,因此您無法使用Wikipedia 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]); 

本例使用的名稱,以及谷歌廣場LAT/LNG並搜索「位置」類型的遊離鹼DB爲內它百英尺該名稱的Lat/LNG。

我敢肯定,代碼可以做得更好,但它迄今爲止效果很好。

ALSO - 值得注意的是 - 當您爲谷歌搜索「地點」時,它會顯示Google搜索FreeBase FIRST,然後將該結果與相似的Google地方信息結果進行匹配。 這就是爲什麼當你在谷歌搜索某個地點時,右邊的結果可能與谷歌地方的結果命名不同,並且有一個描述,但是如果你使用「near」,你會注意到現在相同的地方沒有描述。例如 - 我在倫敦安大略省加拿大,我可以搜索'Fanshawe學院',結果是'Fanshawe學院',其中包括描述..但是,在地圖小程序中,指針位於Google Place,名爲'Fanshawe學院 - 倫敦校區「如果我搜索'倫敦附近的fanshawe學院',它指定我在找一個地方;結果我得到'Fanshawe學院 - 倫敦校園'沒有描述和較少的信息。