无法获得 formated_address 'only in English' 以区域语言获得部分结果

Not able to get formated_address 'only in English' getting some part of result in regional language

我正在获取区域语言的 google 地图结果的一部分,需要完整的英语结果

我尝试通过将语言更改为 'en' 并将区域更改为 'IN'

来点击地图的 API
$geocode=file_get_contents(https://maps.googleapis.com/maps/api/geocode/json?latlng=12.9415554,77.5595728&sensor=false&key=MYAPIGOOGLEKRY&language=en&region=IN);
        $geocode_arr=json_decode($geocode,true);
        if(array_key_exists("0",$geocode_arr['results'])){
        $arr_exp=explode(",",$geocode_arr['results'][0]['formatted_address']);
        $arr_exp=array_slice($arr_exp, -4, 3, true);
        $address_str=implode(",",$arr_exp);
        print_r($address_str); exit;
        }

得到结果:

ಬನಶಂಕರಿ, Bengaluru, Karnataka 560050 
('ಬನಶಂಕರಿ' regional language)

预期结果:

XYZ, Bengaluru, Karnataka 560050

这是 Maps API 的预期行为。目前无法仅使用英文 return formatted_address。请参阅 Google's post 关于 Google Maps API 中街道地址的本地化。

Street-level addresses returned by the Google Maps Geocoding API now favor the local language, while keeping the address understandable as much as possible for both a user who only reads the requested language as well as locals.

If the local language and user language both use the same alphabet, the Geocoding API will now return the local names for the streets and localities. For example, searching for an address in Brazil with user language set to English now returns “Avenida Paulista” rather than “Paulista Avenue”.

所以这个示例请求:

https://maps.googleapis.com/maps/api/geocode/json?address=Avenida+Paulista,+Bela+Vista&key=KEY

return是这个:

formatted_address: "Av. Paulista - Bela Vista, São Paulo - SP, Brazil"

Geocoding documentation也提到了这个:

The geocoder does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.

希望这能回答您的问题。