地图服务器无法返回期望的信息,PHP的服务器地理编码与谷歌地图返回状态确定,但没有别的...

static private function curl_file_get_contents($URL){

$c = curl_init();

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_URL, $URL);

$contents = curl_exec($c);

curl_close($c);

if ($contents) return $contents;

else return FALSE;

}

public function preview(Request $request)

{

$url = "https://maps.googleapis.com/maps/api/geocode/json?key=my_api_key&address=1600+Amphitheatre+Parkway,+Mountain+View,+CA";

$resp_json = self::curl_file_get_contents($url);

$resp = json_decode($resp_json, true);

if($resp['status']='OK'){

dd($resp);

}else{

dd('not ok');

}

当我运行这个我的状态是OK和dd($ resp);得到执行,其输出只是这样的:

array:1 [▼

"status" => "OK"

]

应该还有很多更应返回,但在我的情况下,它不会被退回。我不知道它为什么能有什么关系我跑这个地方,虽然在这种情况下,它不应该返回状态:OK

编辑例如: 如果我过去,这为浏览器直接

那么很多返回更多的数据

{

"results" : [

{

"address_components" : [

{

"long_name" : "1600",

"short_name" : "1600",

"types" : [ "street_number" ]

},

{

"long_name" : "Amphitheatre Parkway",

"short_name" : "Amphitheatre Pkwy",

"types" : [ "route" ]

},

{

"long_name" : "Mountain View",

"short_name" : "Mountain View",

"types" : [ "locality", "political" ]

},

{

"long_name" : "Santa Clara County",

"short_name" : "Santa Clara County",

"types" : [ "administrative_area_level_2", "political" ]

},

{

"long_name" : "California",

"short_name" : "CA",

"types" : [ "administrative_area_level_1", "political" ]

},

{

"long_name" : "USA",

"short_name" : "US",

"types" : [ "country", "political" ]

},

{

"long_name" : "94043",

"short_name" : "94043",

"types" : [ "postal_code" ]

}

],

"formatted_address" : "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",

"geometry" : {

"location" : {

"lat" : 37.4223664,

"lng" : -122.084406

},

"location_type" : "ROOFTOP",

"viewport" : {

"northeast" : {

"lat" : 37.4237153802915,

"lng" : -122.0830570197085

},

"southwest" : {

"lat" : 37.42101741970851,

"lng" : -122.0857549802915

}

}

},

"place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",

"types" : [ "street_address" ]

}

],

"status" : "OK"

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值