Javascript 如何在 Google Maps API 中指示语言?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2662889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to indicate the language in the Google Maps API?
提问by Matt
Just like you visit maps.google.com.twor maps.google.co.kror maps.google.co.jp, you can see their own language shown on every country. Is there any property that I can use in Google Maps API to dynamically set google maps using specific language to display?
就像您访问maps.google.com.tw或maps.google.co.kr或者maps.google.co.jp,你可以看到每一个国家都显示出他们自己的语言。我可以在 Google Maps API 中使用任何属性来动态设置使用特定语言显示的谷歌地图吗?
回答by Maksym Kozlenko
In Google Maps API v3, add "language" attribute to script tag. For example, the following will set map to display Russian in location names and navigation buttons:
在 Google Maps API v3 中,为 script 标签添加“language”属性。例如,以下将设置地图以在位置名称和导航按钮中显示俄语:
<script
src="http://maps.google.com/maps/api/js?sensor=false&language=ru-RU"
type="text/javascript"></script>
Result:
结果:


回答by Jelena
In Google Maps v3, you can use the "language" parameter:
在 Google Maps v3 中,您可以使用“语言”参数:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script>
Language codes list: https://developers.google.com/maps/faq#languagesupport
语言代码列表:https: //developers.google.com/maps/faq#languagesupport
More info: http://googlegeodevelopers.blogspot.com/2009/10/maps-api-v3-now-speaks-your-language.html
更多信息:http: //googlegeodevelopers.blogspot.com/2009/10/maps-api-v3-now-speaks-your-language.html
回答by Daniel Vassallo
For the V2 Maps API:
对于 V2 地图 API:
You can add an optional hlparameter to the <script>tag when including the Google Maps API, specifying the domain language to use, as in the following example:
您可以在包含 Google Maps API 时hl向<script>标记添加可选参数,指定要使用的域语言,如下例所示:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Localization of the Google Maps API</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&hl=ko"
type="text/javascript"></script>
</head>
<body onunload="GUnload()">
<div id="map_canvas" style="width: 400px; height: 300px"></div>
<script type="text/javascript">
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(36.48, 128.00), 7);
map.setUIToDefault();
</script>
</body>
</html>
Screenshot:
截屏:


You may also want to check out the following resources for further reading:
您可能还想查看以下资源以进一步阅读:
回答by lbsweek
language code is IETF language code:
语言代码为 IETF 语言代码:
http://en.wikipedia.org/wiki/IETF_language_tag
http://en.wikipedia.org/wiki/IETF_language_tag
<script
src="http://maps.google.com/maps/api/js?sensor=false&language=ru-RU"
type="text/javascript"></script>

