上传地址,获得经度纬度:
$newdata = urlencode(地址);
$url = "http://api.map.baidu.com/geocoder/v2/?address=".$newdata."&output=json&ak=需自己申请";
$address_data = file_get_contents($url);
$json_data = json_decode($address_data);
$lng = $json_data->result->location->lng;
$lat = $json_data->result->location->lat;
网友评论