標籤:
為了在APP中根據定位實現搜尋附近(POI)的功能,採用百度LBS雲端服務,將所有POI資料上傳後,可以實現該功能。
LBS資料管理地址:在這裡標記資訊後(支援批量上傳)即可開始使用搜尋功能。
http://lbsyun.baidu.com/datamanager/datamanage
搜尋附近介面地址:
http://api.map.baidu.com/geosearch/v3/nearby
請求方式:
GET
參數:
{ak:‘540b088ff0f926b7d0b6d5a641******‘, //app key,需要到百度開放平台申請geotable_id:89059, //資料表id,在上面的LBS資料管理地址中擷取 location=117.118675,39.078544, //使用者座標或經緯度,需要擷取定位coord_type:3, //座標類別,3表示百度座標,請看下面的說明radius:1000, //搜尋範圍,單位米,page_index:0 , //頁碼page_size:10 , //每頁顯示記錄條數q:‘美特斯邦威‘, //關鍵詞,將對附近的店鋪再次匹配搜尋,可為空白
sortby:distance:1 //按距離升序排列,-1表示降序}/**coord_type說明,請根據自己獲得的location資訊來改變該參數,採用百度定位SDK應設定為3,
採用HTML5定位應該設定為11:GPS經緯度座標2:國測局加密經緯度座標3:百度加密經緯度座標4:百度加密墨卡托座標**/
傳回值:
{ "status": 0, "total": 5,//結果數 "size": 5, "contents": [ { "title": "天津", //地點名稱 "location": [ 117.068811, 39.062756 ], "city": "天津市", "create_time": 1419229456, "geotable_id": 89059, "address": "天津", "tags": "", "province": "天津市", "district": "西青區", "uid": 576117245, "coord_type": 3, "type": 0, "distance": 4650, //距離,單位米 "weight": 315 }, { "address": "天津市河北區金緯路111號(米蘭超市河北店)外1號", "city": "天津市", "create_time": 1419053693, "district": "河北區", "geotable_id": 89059, "icon_style_id": "sid1", "location": [ 117.208617, 39.155932 ], "modify_time": 1419229238, "province": "天津市", "tags": "商鋪", "title": "美特斯邦威(金緯路店)", "uid": 574315040, "coord_type": 3, "type": 0, "distance": 11580, "weight": 54 }, { "address": "天津市和平區和平路194-196號", "city": "天津市", "create_time": 1419053596, "district": "和平區", "geotable_id": 89059, "icon_style_id": "sid1", "location": [ 117.201581, 39.135009 ], "modify_time": 1419229243, "province": "天津市", "title": "美特斯邦威(和平路店)", "uid": 574314000, "coord_type": 3, "type": 0, "distance": 9515, "weight": 54 }, { "address": "天津市河西區大沽南路華潤萬家南樓北店1樓(近東樓)", "city": "天津市", "create_time": 1419226421, "district": "河西區", "geotable_id": 89059, "icon_style_id": "sid1", "location": [ 117.230504, 39.103007 ], "modify_time": 1419229272, "province": "天津市", "title": "美特斯邦威(南樓北店)", "uid": 576070688, "coord_type": 3, "type": 0, "distance": 10037, "weight": 54 }, { "address": "天津市和平區濱江道153號一層至二層和華中路2號的一層至四層", "city": "天津市", "create_time": 1419053799, "district": "和平區", "geotable_id": 89059, "icon_style_id": "sid1", "location": [ 117.204502, 39.128208 ], "modify_time": 1419229233, "province": "天津市", "tags": "商鋪", "title": "美特斯邦威(濱江道店)", "uid": 574316229, "coord_type": 3, "type": 0, "distance": 9238, "weight": 54 } ]}
返回參數詳細表格,可供參考:
這樣,就實現了搜尋附近功能,依託百度的雲平台,我們可以得到比較穩定的服務。
百度LBS開放平台還提供了一個搜尋指定地區的介面,和搜尋附近是不一樣的,可以根據實際需求來選用,詳細內容這裡就不介紹了,有興趣的可以參考百度LBS雲的開發人員文檔。
APP搜尋附近功能的一種解決方案-基於百度LBS雲端服務