function getLoLa($add)
{
$baiduAK = 'https://api.map.baidu.com/geocoding/v3/?address=' . $add . '&output=json&ak=11Z8uiP8kIz6AG0Vjiwzbc5f9Ii0cdHd&callback=showLocation';
$lola = file_get_contents($baiduAK);
return $lola;
}
function strRe($str)
{
$b = str_replace('showLocation&&showLocation', '', $str);
$b = str_replace('(', '', $b);
$b = str_replace(')', '', $b);
$c = json_decode($b, true);
return $c;
}
echo "";
$a = strRe(getLoLa('宁波市鄞州区泰康中路558号'));
//var_dump($a);
echo $a["result"]["location"]["lng"];
echo "";
echo $a["result"]["location"]["lat"];
//var_dump($a);
/*echo "";
var_dump($a);*/
PHP根据地址逆向解析经纬度
关注
打赏