Google Places API的详细信息语言无法使用 [英] Google Places API details language not working

查看:116
本文介绍了Google Places API的详细信息语言无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个双语项目,并开始使用Google Places API Webservices。我开始使用放置自动填充API ,效果很好。



我可以在 fr en 中执行此查询并获得不同的描述结果:


https://maps.googleapis.com/maps/api/place/autocomplete/json?key= < insert_key_here> & types = geocode& language = < insert_language_here> & input = 144



英文结果:

 description:加拿大魁北克省Gouin Boulevard West,14458,
id:33dcffeeb88b48fa5c1d0ec4e6e54469d05f5d1e,
place_id:ChIJk0pAHBM7yUwRt0WIxWRe1ic,

法语结果:
$ b $

description:14458 Boulevard Gouin Ouest,QC,Canada,
id: 33 dcffeeb88b48fa5c1d0ec4e6e54469d05f5d1e,
place_id:ChIJk0pAHBM7yUwRt0WIxWRe1ic,

完全相同但文本是本地化的,这是预期的结果。现在,当我尝试使用放置详细信息API 获得相同的结果时,语言参数似乎没有任何影响。我知道如果可能的话,文档中提到结果应该被返回。但是我知道这是可能的,这是行为的设计还是某种错误?



以下是使用前面的示例place_id查询英语详细信息的示例,它以法语结果返回结果:


https://maps.googleapis.com/maps/ api / place / details / json?key = < insert_key_here> & placeid = ChIJk0pAHBM7yUwRt0WIxWRe1ic& language = zh_CN
blockquote>

 long_name:Boulevard Gouin Ouest,


解决方案

在进行更多研究时,看起来这是Google Places详细信息API的一个旧/已知问题。我确实在此处发布了一些新问题,但因为这已经被多次报道了,所以没有办法知道他们是否会修复这个问题。



旧的2012线程也可以找到类似的问题这里



以前的 stackoverflow帖子中提出了一些解决方法。 a>但是对于我给出的用例,它没有任何好处。



目前,我唯一能想到的唯一选择就是使用Google Translate API这是不幸的是没有免费的。鉴于细节的反应,人们可以解析每个领域并在重建地址之前尝试翻译它们。考虑到无法预测机器翻译如何在所有情况下都能正常工作,这当然是有风险的/脆弱的。在Google Places API中支持本地化将是更简单的选择,并让很多用户开心。


I am working on a bilingual project and started to use Google Places API Webservices. I started using the Place Autocomplete API which works great.

I can do this query in both fr and en and will get different description results:

https://maps.googleapis.com/maps/api/place/autocomplete/json?key=<insert_key_here>&types=geocode&language=<insert_language_here>&input=144

English result:

  "description": "14458 Gouin Boulevard West, QC, Canada",
  "id": "33dcffeeb88b48fa5c1d0ec4e6e54469d05f5d1e",
  "place_id": "ChIJk0pAHBM7yUwRt0WIxWRe1ic",

French result:

  "description": "14458 Boulevard Gouin Ouest, QC, Canada",
  "id": "33dcffeeb88b48fa5c1d0ec4e6e54469d05f5d1e",
  "place_id": "ChIJk0pAHBM7yUwRt0WIxWRe1ic",

The ids are exactly the same but the text is localized which is the expected result. Now when I try to get the same result using the Place Details API, the language parameter doesn't seem to have any impact. I know that the documentation mentions results should be returned, if possible. but given I know it is possible, is this behavior by design or some sort of bug?

Here is an example of an english details query using the previous example place_id which returns the result in french:

https://maps.googleapis.com/maps/api/place/details/json?key=<insert_key_here>&placeid=ChIJk0pAHBM7yUwRt0WIxWRe1ic&language=en

    "long_name": "Boulevard Gouin Ouest",

解决方案

While doing more researches, it looks like this is an old/known problem with the Google Places Details API. I did open a new issues here but given this has been reported multiple times there is no way to know when/if they will fix this.

An old 2012 thread can also be found with similar problems here.

Some workaround have been suggested in a previous stackoverflow post but for my given use case it did not do any good.

For the time being, the only real option I could think of would be to use Google Translate API which is unfortunately not free. Given the detail's response, one could parse every field and try to translate them before rebuilding an address. This would of course be a risky/fragile given that one cannot predict how the machine translation will work in all scenarios. Having Google support localization in their Places API would be much simpler option and make a lot of users happy.

这篇关于Google Places API的详细信息语言无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆