繁体   English   中英

更改Geocoder.geocode()返回结果的语言

[英]Change the language in which Geocoder.geocode() returns results

正如API参考声明:

The Geocoding API defines a geocoding request using the following URL parameters:

 - language (optional) — The language in which to return results. See the supported list of domain languages. Note that we often update supported languages so this list may not be exhaustive. If language is not supplied, the geocoder will attempt to use the native language of the domain from which the request is sent wherever possible.

但是,指定language参数似乎没有效果(使用Firefox 8,IE 9和Chrome 15测试)。

new google.maps.Geocoder().geocode({
    'latLng'  : new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
    'language': 'en'}, 
    function(results, status) {}
);

您引用的API链接与您在代码示例中使用的API链接不同。

我相信你正在寻找的是这个API ,这让我想知道上面如何返回任何恢复,因为它期望一个bounds而不是latLng ,并且它也不支持language密钥。

但是,为了使用其他语言获得结果,您可以根据文档的此部分更改包含Google地图脚本的方式,例如

<script type="text/javascript" 
src="http://maps.googleapis.com/maps/api/js?sensor=false&language=ja"></script>

另一方面,如果你真的使用地理编码API(Web服务) ,那么你的url请求需要看起来像这样(如果你想要xml out,将json更改为xml,并将en更改为你想要的任何语言)

http://maps.googleapis.com/maps/api/geocode/json?latlng=YOUR-LAT-LNG&language=en

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM