腾讯地图通过详细地址获取经纬度---php代码

//获取经纬度腾讯

private function get_lng_lat_tx($address){

    $url = "https://apis.map.qq.com/ws/geocoder/v1/?address='地址'&key='key值(字符串)'";
    
    $result = curl_get($url);
    if($result)
    {
        $data = array();
        $res= json_decode($result,true); 
        if ($res['status'] == 0) {
            $results = $res['result'];
            $data['lng'] = $results['location']['lng'];
            $data['lat'] = $results['location']['lat'];
        }
        return $data;
    }
    else{
        return 0;
    }
}

你可能感兴趣的:(php,tp5,tp3整理)