3

现在有人如何为反向地理编码 php 响应设置语言吗?(总是设置 en)

**Here is the code**
<code>
$api_key = "***";

$url = 'http://maps.google.com/maps/geo?q=49.8411860,30.1066580&output=json&sensor=true_or_false&key=' . $api_key.'&language=uk';

$data = @file_get_contents($url);

$jsondata = json_decode($data,true);

if(is_array($jsondata )&& $jsondata ['Status']['code']==200) {
      $addr = $jsondata ['Placemark'][0]['address'];
}

echo $addr;
</code>
**The Output is**

"L'va Tolstoho street, Bila Tserkva, Kyivs'ka oblast, Ukraine"
4

1 回答 1

2

如果您想要英语,请将您的 URI 变量语言更改为 'en' 即 &language=en

$url = 'http://maps.google.com/maps/geo?q=49.8411860,30.1066580&output=json&sensor=true_or_false&key=' . $api_key.'&language=en';

Google Maps API 本地化参考指南

查看维基百科上所有语言代码的列表

于 2013-02-11T15:32:21.223 回答