一款LBS API元件.
Installing
$ composer require gundy/easylbs -vvv
配置
在使用本擴充套件之前,你需要去 騰訊位置服務 註冊賬號,然後建立應用,獲取應用的 API Key。
Usage
use Gundy\Easylbs\Factory;
// 騰訊地圖LBS API Key
$key = 'L3JBZ-XR6KV-7LKPK-UUXQC-MV35S-4BFTQ';
$config = [
'key' => $key
];
$app = Factory::QQ($config);
地點搜尋
$params =[
'keyword' => "酒店",
'boundary' => 'region(北京,0)',
];
$res = $app->searchPlace($params);
print_r($res);
示例:
{
"status": 0,
"message": "query ok",
"count": 2500,
"request_id": "060190230178738eb646eb2eb072f5eb11adebb3f5e6",
"data": [
{
"id": "7987947683463136249",
"title": "永泰福朋喜來登酒店",
"address": "北京市海淀區遠大路25號",
"tel": "010-88898800; 010-88898888",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.95775,
"lng": 116.27974
},
"ad_info": {
"adcode": 110108,
"province": "北京市",
"city": "北京市",
"district": "海淀區"
}
},
{
"id": "2892798972637244762",
"title": "雲峰山童話樹屋",
"address": "北京市密雲區燕落村雲峰山自然風景區內",
"tel": "010-81098688",
"category": "酒店賓館:酒店賓館",
"type": 0,
"location": {
"lat": 40.589124,
"lng": 116.956674
},
"ad_info": {
"adcode": 110118,
"province": "北京市",
"city": "北京市",
"district": "密雲區"
}
},
{
"id": "1043299057989721718",
"title": "尚隱·泉都市生活館",
"address": "北京市豐臺區小屯雙林東路8號",
"tel": " ",
"category": "酒店賓館:度假村",
"type": 0,
"location": {
"lat": 39.877316,
"lng": 116.256397
},
"ad_info": {
"adcode": 110106,
"province": "北京市",
"city": "北京市",
"district": "豐臺區"
}
},
{
"id": "9718531218220139859",
"title": "北京會議中心",
"address": "北京市朝陽區來廣營西路88號",
"tel": "010-84901668;010-84901458;010-84901459",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 40.021,
"lng": 116.42843
},
"ad_info": {
"adcode": 110105,
"province": "北京市",
"city": "北京市",
"district": "朝陽區"
}
},
{
"id": "883837519094177688",
"title": "釣魚臺國賓館",
"address": "北京市海淀區阜成路2號",
"tel": "010-58591188",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.92271,
"lng": 116.33236
},
"ad_info": {
"adcode": 110108,
"province": "北京市",
"city": "北京市",
"district": "海淀區"
}
},
{
"id": "13833155074774121278",
"title": "北京香格里拉飯店",
"address": "北京市海淀區紫竹院路29號",
"tel": "010-68412211",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.944455,
"lng": 116.308329
},
"ad_info": {
"adcode": 110108,
"province": "北京市",
"city": "北京市",
"district": "海淀區"
}
},
{
"id": "3161565500563468633",
"title": "首都大酒店",
"address": "北京市東城區前門東大街3號",
"tel": "010-58159988;010-65120309",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.901864,
"lng": 116.409227
},
"ad_info": {
"adcode": 110101,
"province": "北京市",
"city": "北京市",
"district": "東城區"
}
},
{
"id": "14241478084495387329",
"title": "北京飯店",
"address": "北京市東城區東長安街33號",
"tel": "010-65137766",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.90901,
"lng": 116.4101
},
"ad_info": {
"adcode": 110101,
"province": "北京市",
"city": "北京市",
"district": "東城區"
}
},
{
"id": "294853408830955987",
"title": "北京國際飯店",
"address": "北京市東城區建國門內大街9號",
"tel": "010-65126688",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.90981,
"lng": 116.42857
},
"ad_info": {
"adcode": 110101,
"province": "北京市",
"city": "北京市",
"district": "東城區"
}
},
{
"id": "5870241694364570788",
"title": "北京遠通維景國際大酒店",
"address": "北京市西城區平安裡西大街30號",
"tel": "010-66026688",
"category": "酒店賓館:星級酒店",
"type": 0,
"location": {
"lat": 39.9313,
"lng": 116.35678
},
"ad_info": {
"adcode": 110102,
"province": "北京市",
"city": "北京市",
"district": "西城區"
}
}
],
"region": {
"title": "北京市"
}
}
自定義請求
$params = [
'from' => '39.984042,116.307535',
'to' => '39.976249,116.316569'
];
$res = $app->sendRequest('/ws/direction/v1/walking', $params);
Documentation
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
todo
- 整合百度地圖服務
- 整合高德地圖服務
- 適配Laravel框架