Commit 273b73c5 authored by zhuwei's avatar zhuwei

百度接口-根据城市商圈获取经纬度 优化

parent 3fff4fd2
...@@ -68,29 +68,5 @@ class BatchProcessing extends Basic ...@@ -68,29 +68,5 @@ class BatchProcessing extends Basic
} }
/**
* @param string $address 地址
* @param string $city 城市名
* @return array
*/
function getLatLng($address='',$city='')
{
$result = array();
$ak = 'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s';//您的百度地图ak,可以去百度开发者中心去免费申请
$url ="http://api.map.baidu.com/geocoder/v2/?callback=renderOption&output=json&address=".$address."&city=".$city."&ak=".$ak;
$data = file_get_contents($url);
$data = str_replace('renderOption&&renderOption(', '', $data);
$data = str_replace(')', '', $data);
$data = json_decode($data,true);
if (!empty($data) && $data['status'] == 0) {
$result['lat'] = $data['result']['location']['lat'];
$result['lng'] = $data['result']['location']['lng'];
return $result;//返回经纬度结果
}else{
return null;
}
}
} }
...@@ -393,6 +393,7 @@ class HouseService ...@@ -393,6 +393,7 @@ class HouseService
/** /**
* 百度接口-根据城市商圈获取经纬度
* @param string $address 地址 * @param string $address 地址
* @param string $city 城市名 * @param string $city 城市名
* @return array * @return array
...@@ -400,7 +401,7 @@ class HouseService ...@@ -400,7 +401,7 @@ class HouseService
function getLatLng($address='',$city='') function getLatLng($address='',$city='')
{ {
$result = array(); $result = array();
$ak = 'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s';//您的百度地图ak,可以去百度开发者中心去免费申请 $ak = 'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s';//百度地图ak,百度开发者中心去免费申请
$url ="http://api.map.baidu.com/geocoder/v2/?callback=renderOption&output=json&address=".$address."&city=".$city."&ak=".$ak; $url ="http://api.map.baidu.com/geocoder/v2/?callback=renderOption&output=json&address=".$address."&city=".$city."&ak=".$ak;
$data = file_get_contents($url); $data = file_get_contents($url);
$data = str_replace('renderOption&&renderOption(', '', $data); $data = str_replace('renderOption&&renderOption(', '', $data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment