Google Places API(实验性)
google 圖庫
https://sites.google.com/site/gmapsdevelopment/
【key】使用 GCM(Google Cloud Messaging)
API Access 選項,點擊 "Create new Server key...",直接按左下角的 Create 鈕,您會看到 API key測試Key: https://developers.google.com/places/documentation/search?hl=zh-tw
Code Samples
Libraries
'icon': item.icon ,
http://maps.gstatic.com/mapfiles/place_api/icons/university-71.png
http://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png
Supported Place Types

types: ['school'] //bank 此型態是Array 要注意轉換
var typesString = document.getElementById('placeTypes').value; //抓取選擇的地點類型值 cafe var typesArray=new Array(typesString); //cafe ->['cafe'] // alert(Object.prototype.toString.call(typesArray) ); 查資料形態 var request = { location: pyrmont, radius: radius, types: typesArray //['cafe'] };
找地址 (透過textsearch 因為只有textsearch才支援formatted_address查詢)
error_reporting(E_ALL^E_NOTICE^E_WARNING); header('Content-Type: text/html; charset=utf-8'); //中文記得設定language=zh-tw //$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=25.047908,121.517315&sensor=false&language=zh-tw"; $url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=統一星巴克美麗華門市&sensor=false&key=yourkey&language=zh-tw"; $json = file_get_contents($url); //echo $json ; $arr_json = json_decode($json); // 注意! formatted_address property is only returned for a Text Search. $formatted_address = $arr_json->results[0]->formatted_address; echo $formatted_address ; //台灣台北市中山區敬業三路20號
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。