簡體   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