|
@@ -714,4 +714,39 @@ class ApiController extends BaseController
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //腾讯地图逆地址解析
|
|
|
|
+ public function positionGeocoder(){
|
|
|
|
+ $lat = Input::get('lat', '');//纬度
|
|
|
|
+ $lng = Input::get('lng', '');//经度
|
|
|
|
+
|
|
|
|
+ if (!$lat) {
|
|
|
|
+ return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!$lng) {
|
|
|
|
+ return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $gps = $lat.','.$lng;
|
|
|
|
+
|
|
|
|
+ $params = [
|
|
|
|
+ 'location' => $gps,
|
|
|
|
+ 'key' => env('TX_KEY')
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $result = $this->sendRequest("https://apis.map.qq.com/ws/geocoder/v1",$params);
|
|
|
|
+
|
|
|
|
+ dd($result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //腾讯位置接口服务
|
|
|
|
+ public function sendRequest($url, $params) {
|
|
|
|
+ $ch = curl_init();
|
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params));
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
+ $response = curl_exec($ch);
|
|
|
|
+ curl_close($ch);
|
|
|
|
+ return json_decode($response, true);
|
|
|
|
+ }
|
|
}
|
|
}
|