微信公共号 获得用户的 经纬度坐标后,使用百度地图API转换为具体的街道信息:
代码如下:
case “LOCATION”:
//$content = “上传位置:纬度 “.$object->Latitude.”;经度 “.$object->Longitude.”;位置:”.$object->Label;
//$url=”http://api.map.baidu.com/geocoder/v2/?ak=i48sSQiIjl6UPkR0TFGsU2qn&location=$object->Latitude,$object->Longitude&output=json&coordtype=gcj0211″;
$url=”http://api.map.baidu.com/geocoder/v2/?ak=i48sSQiIjl6UPkR0TFGsU2qn&callback=renderReverse&location=$object->Latitude,$object->Longitude&output=json&pois=1″;
$output=file_get_contents($url);
$address=json_decode($output,true);
$content=”位置-:”.$address[“result”][“addressComponent”][“province”].” “.$address[“result”][“addressComponent”][“city”].” “.$address[“result”][“addressComponent”][“district”].” “.$address[“result”][“addressComponent”][“street”];
break;
为什么获取坐标转换后 的内容为空
代码如下:
case “LOCATION”:
//$content = “上传位置:纬度 “.$object->Latitude.”;经度 “.$object->Longitude.”;位置:”.$object->Label;
//$url=”http://api.map.baidu.com/geocoder/v2/?ak=i48sSQiIjl6UPkR0TFGsU2qn&location=$object->Latitude,$object->Longitude&output=json&coordtype=gcj0211″;
$url=”http://api.map.baidu.com/geocoder/v2/?ak=i48sSQiIjl6UPkR0TFGsU2qn&callback=renderReverse&location=$object->Latitude,$object->Longitude&output=json&pois=1″;
$output=file_get_contents($url);
$address=json_decode($output,true);
$content=”位置-:”.$address[“result”][“addressComponent”][“province”].” “.$address[“result”][“addressComponent”][“city”].” “.$address[“result”][“addressComponent”][“district”].” “.$address[“result”][“addressComponent”][“street”];
break;
为什么获取坐标转换后 的内容为空
解决方案