根据经纬度获取国家

 
'google_map' => 'AIzaSyAVnXMeSd_Nmnaw2LV1mJsiIW8PcM2elXs'

$google_map = config('map.google_map');
        // 121.57798111,25.0465111 台湾
        // 100.501954,13.750575 泰国
        $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=$latitude,$longitude&key=".$google_map;
        $data = json_decode(curl_get_https($url), true);
        $res =  $data['plus_code']['compound_code'];
        if (strpos($res,',')!==false){
            $country = explode(',',$data['plus_code']['compound_code']);
        }else{
            $country= explode(' ',$data['plus_code']['compound_code']);
        }

 

你可能感兴趣的:(根据经纬度获取国家)