默认情况下,在地图上显示控件名称、版权声明、行车路线和标签等文本信息时,Maps JavaScript API 会使用用户在浏览器中指定的首选语言设置。在大多数情况下,最好遵循浏览器的设置。不过,如果您希望 Maps JavaScript API 忽略浏览器的语言设置,可以在加载 Maps JavaScript API 代码时向 <script> 标记添加一个 language 参数,强制浏览器以特定语言显示信息。
language 参数会影响控件名称、版权声明、行车路线和控件标签,以及对服务请求的响应。但对服务的影响则不这么明显。例如,在对街道级地址进行地理编码时,系统会以您请求的语言返回国家/地区名称,但地址的其余部分则取决于您要进行地理编码的位置。另一方面,邮政和政区结果会以请求的语言返回。不妨试用此演示版应用,体验一下在更新 language 参数时地图上发生的变化。
如果您想更改应用以使其提供不同的地图图块,或者使应用具有偏向(例如,使地理编码结果偏向于相应区域),请在加载 Maps JavaScript API 代码时向 <script> 标记添加 region 参数。
您是 Maps JavaScript API 应用的开发者,我们建议您始终设置 region 参数,因为设置 region 后,各种服务(例如地点自动补全)往往能够提供更好的结果。您也有责任确保在部署应用的国家/地区进行正确的区域本地化,以确保您的应用符合当地法律。
region 参数接受 Unicode 地区子标记标识符,后者(通常)与国家/地区代码一级的顶级域名 (ccTLD) 存在一对一映射关系。除了某些明显的例外情况之外,大多数 Unicode 区域标识符都与 ISO 3166-1 alpha-2 代码完全一致。例如,英国的 ccTLD 为“uk”(对应于域名 .co.uk),但其区域标识符为“GB”。如需了解支持的地区,请参阅 Google Maps Platform 覆盖范围详细信息。不妨试用此演示版应用,体验一下在更新 region 参数时地图上发生的变化。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-06。"],[[["\u003cp\u003eCustomize your map by adjusting the default language and specifying a region code for tailored behavior.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003elanguage\u003c/code\u003e parameter in the script tag to display map information in a specific language, overriding browser settings if needed.\u003c/p\u003e\n"],["\u003cp\u003eApply the \u003ccode\u003eregion\u003c/code\u003e parameter in the script tag to refine map tiles, bias application results, and ensure compliance with local laws.\u003c/p\u003e\n"],["\u003cp\u003eFor optimal results and legal adherence, consider setting both \u003ccode\u003elanguage\u003c/code\u003e and \u003ccode\u003eregion\u003c/code\u003e parameters when localizing your map.\u003c/p\u003e\n"]]],["To customize a map, specify a `language` and `region` parameter in the `\u003cscript\u003e` tag when loading the Maps JavaScript API. The `language` parameter sets the display language for controls, directions, and service responses, overriding the browser's default. The `region` parameter alters map tiles and biases service results, like geocoding. Setting both is crucial for legal compliance and service accuracy. For example, you can set the language to Japanese and the region to Japan by setting `language=ja` and `region=JP`.\n"],null,["You can customize your map for a specific country or region in the following\nways:\n\n- Change the default language settings.\n- Specify a region code, which alters the map's behavior based on a given country or territory.\n\nLanguage localization\n\nBy default, the Maps JavaScript API uses the user's preferred\nlanguage setting as specified in the browser, when displaying textual\ninformation such as the names for controls, copyright notices, driving\ndirections and labels on maps. In most cases, it's preferable to respect the\nbrowser setting. However, if you want the\nMaps JavaScript API to ignore the browser's\nlanguage setting, you can force it to display information in a particular\nlanguage by adding a `language` parameter to the\n`\u003cscript\u003e` tag when loading the\nMaps JavaScript API code.\n\nThe `language` parameter affects the names of controls, copyright\nnotices, driving directions, and control labels, as well as the responses to\nservice requests. The effect on services is not as apparent. For example, when\ngeocoding street level addresses the country name is returned in the language\nyou requested, but the rest of the address will be specific to the location\nyou are geocoding. On the other hand, postal and political results are\nreturned in the requested language.\nTry [this demo](/maps/documentation/javascript/demos/localization) to experiment with the changes on the map when you update the\n`language` parameter.\n\nThe following example displays a map in Japanese and sets the region to\nJapan: \n\n```html\n\u003cscript async\n src=\"https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=JP&language=ja&callback=initMap\"\u003e\n\u003c/script\u003e\n```\n\n[View\nexample](/maps/documentation/javascript/examples/map-language).\n\nIf you set the language of the map, it's important to\nconsider setting the [region](#Region) too. This helps ensure\nthat your application complies with local laws.\n\n**Note:** When you load the API in the manner shown above, the\nmap uses the Japanese language for all users regardless of user preferences.\nBe sure you want this behavior before setting this option.\n\nThe Maps JavaScript API also supports bi-directional\n(Bidi) text containing characters in both left-to-right (LTR) and\nright-to-left (RTL) languages natively. Examples of RTL languages include\nArabic, Hebrew, and Farsi. Generally, you should specify RTL language pages to\nrender properly by adding `dir='rtl'` to the page's\n`\u003chtml\u003e` element. The following example renders a map of\nCairo, Egypt using Arabic controls: \n\n```html\n\u003cscript async\n src=\"https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=EG&language=ar&callback=initMap\"\u003e\n\u003c/script\u003e\n```\n\n[View example](/maps/documentation/javascript/examples/map-rtl)\n\nSee the [list of supported\nlanguages](/maps/faq#languagesupport). Note that new languages are added often, so this list may not\nbe exhaustive.\n\nRegion localization\n\nAdd a `region` parameter to the `\u003cscript\u003e` tag\nwhen loading the Maps JavaScript API code, if you\nwant to alter your application to serve different map tiles or bias the\napplication (such as biasing geocoding results towards the region).\n\nAs the developer of a Maps JavaScript API\napplication you are encouraged to always set a `region` parameter as various services\n(such as Places Autocomplete) tend to provide better results when the `region` is set.\nIt is also your responsibility to ensure that your application complies with local laws by\nensuring that the correct region localization is applied for the country in which the application\nis hosted.\n\nThe `region` parameter accepts\n[Unicode region subtag identifiers](http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers) which (generally) have a\none-to-one mapping to country code Top-Level Domains (ccTLDs). Most Unicode\nregion identifiers are identical to ISO 3166-1 alpha-2 codes, with some\nnotable exceptions. For example, Great Britain's ccTLD is \"uk\" (corresponding\nto the domain `.co.uk`) while its region identifier is \"GB.\" See\n[Google Maps Platform Coverage Details](/maps/coverage) for\nsupported regions.\nTry [this demo](/maps/documentation/javascript/demos/localization) to experiment with the changes on the map when you update the\n`region` parameter.\n\nFor example, the following script tag localizes the map to the United\nKingdom: \n\n```html\n\u003cscript async\n src=\"https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=GB&callback=initMap\"\u003e\n\u003c/script\u003e\n```\n\nThe following examples show two maps, one which geocodes \"Toledo\" based on\na `region` set to `US` (US) to \"Toledo, Ohio\" and one\nwhich biases results based on a `region` set to `ES`\n(Spain) to \"Toledo, Spain.\" \n\nView the\n[US\nexample](/maps/documentation/javascript/examples/geocoding-region-us) and the\n[ES\nexample](/maps/documentation/javascript/examples/geocoding-region-es).\n\nLocalization Demo\n\nWhen setting the language of the map, it's important to consider setting the region too.\nHere is a demo that allows you to load the map with your choice of language and region.\n\nView this demo in [fullscreen](/maps/documentation/javascript/demos/localization)."]]