【问题标题】:Need to get names of places in English in Google Place Autocomplete需要在 Google Place Autocomplete 中获取英文地名
【发布时间】:2019-07-17 05:44:43
【问题描述】:

我们使用Google Places Autocomplete 来获取用户输入的任何位置的地址。现在,如果用户进入普吉岛,那么返回的地址是泰语而不是英语。

我已尝试将语言设置为英语

我已经尝试过这些选项

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=en">
</script>

我也试过

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=en&region=GB">
</script>

en-AU,en-GPlanguage=en&amp;region=AU 也同样如此。 但我仍然使用Thai 语言而不是English 获得名称。

我想查看English 中的名称而不是Thai

【问题讨论】:

  • 奇怪,默认情况下它对我来说是英文的,当我输入 language=th 然后它变成泰语,但是 language=en 再次变成英语,使用来自 here 的示例代码。也许是因为无论你想要得到什么,你想要得到的地方是什么?也许它只有泰语元数据?如果该地点只有泰语标题,当然,在自动填充结果中无法获得英文标题。例如this place

标签: googleplacesautocomplete


【解决方案1】:

我尝试使用示例代码here 复制该问题,并且我能够获得“Phuket, Thailand”的格式地址,即英文:

查看以下结果:

address_components: [
    {
        long_name: "Phuket",
        short_name: "จ.ภูเก็ต",
        types: [
            "administrative_area_level_1",
            "political"
        ]
    },
    {
        long_name: "Thailand",
        short_name: "TH",
        types: [
            "country",
            "political"
        ]
    }
],
formatted_address: "Phuket, Thailand",
place_id: "ChIJT1JixOIxUDARIbo9BoWayuk",

您可以在 address_components 中获取long_name 或英文版formatted_address

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 2019-03-25
    • 2018-06-15
    • 2019-03-15
    • 2020-08-10
    • 2017-05-09
    相关资源
    最近更新 更多