$lng //我的经度
//将我的经纬度由Google坐标转换为百度地图坐
$url="http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x=".$lng."&y=".$lat."";
$html=file_get_contents($url);
$result=json_decode($html,true);
$x=$result['x'];//经度
$y=$result['y'];//纬度
$lng1= base64_decode($x);//解密
$lat1=base64_decode($y);//解密
//根据经纬度调用百度地图接口获取当前所在城市
$lat //我的纬度
$lng //我的经度
$ak="cSk1C1VfexgxAewccLLOVFgKn9K71NcK";//该值是在百度地图API上面创建应用生成的
$urls="http://api.map.baidu.com/geocoder/v2/?location=".$lat.",".$lng."&output=json&pois=1&ak=".$ak."";
$html=file_get_contents($urls);
$dataarea=json_decode($html,true);
$city=$dataarea['result']['addressComponent']['city'];