diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index 6e0d0a6d..d4241ecf 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -323,14 +323,16 @@ class LocalStore extends Api // 腾讯地图逆编码 public function getLocation() { - $post = $this->request->post(); - $url = 'https://apis.map.qq.com/ws/geocoder/v1?key=' . ConfigServer::get('map', 'tx_map_key') . '&address=' . $post['address']; - $result = file_get_contents($url); - $data = json_decode($result, true); - if ($data['message'] == 'Success') { - return JsonServer::success('', $data['result']['location']); + try { + $post = $this->request->post(); + $url = 'https://apis.map.qq.com/ws/geocoder/v1?key=' . ConfigServer::get('map', 'tx_map_key') . '&address=' . $post['address']; + $result = file_get_contents($url); + $data = json_decode($result, true); + if ($data['message'] == 'Success') { + return JsonServer::success('', $data['result']['location']); + } + } catch(\Exception $e) { + return JsonServer::error($e->getMessage()); } - - return JsonServer::error('地理位置获取失败'); } } \ No newline at end of file