將地圖本地化
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以透過下列方式自訂特定國家/地區或區域的地圖:
- 變更預設語言設定。
- 指定區碼,根據特定國家/地區或地域調整地圖的行為。
語言本地化
根據預設,Maps JavaScript API 會依照使用者在瀏覽器中指定的偏好語言設定來顯示文字資訊,例如地圖上的控制項名稱、版權聲明、行車路線和標籤。在大部分情況下,最好採用瀏覽器設定。不過,如果您希望 Maps JavaScript API 略過瀏覽器的語言設定,可以在載入 Maps JavaScript API 程式碼時為 <script>
標記加入 language
參數,強制瀏覽器以特定語言顯示資訊。
language
參數會影響控制項名稱、版權聲明、行車路線和控制項標籤,以及對服務要求的回應。服務受到的影響並不明顯。舉例來說,對街道層級地址進行地理編碼時,系統會以您要求的語言傳回國家/地區名稱,地址的其餘部分則取決於進行地理編碼的位置。另一方面,郵政和政治結果會以要求的語言傳回。請使用這裡的示範程式碼,瞭解更新 language
參數時地圖上發生的變化。
下例顯示日文地圖,且將區域設為日本:
<script async
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=JP&language=ja&callback=initMap">
</script>
查看範例。
如要設定地圖語言,請務必考慮一併設定區域,這有助於確保您的應用程式符合當地法律規定。
注意:如果您以上述方式載入 API,則無論使用者偏好設定為何,地圖一律會顯示日文。請先確定您希望這樣做,再設定這個選項。
Maps JavaScript API 也原生支援雙向文字 (Bidi),包含由左到右 (LTR) 和由右到左 (RTL) 語言的字元。舉例來說,阿拉伯文、希伯來文和波斯文就屬於由右到左語言。一般來說,如要讓網頁正常顯示由右到左語言,您必須將 dir='rtl'
加入網頁的 <html>
元素。下例使用阿拉伯文控制項轉譯埃及開羅的地圖:
<script async
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=EG&language=ar&callback=initMap">
</script>
查看範例
查看支援語言清單。請注意,我們會經常新增語言,因此這份清單可能不完整。
區域本地化
如要修改應用程式的地圖圖塊或自訂調整 (例如根據特定區域調整地理編碼結果),您可以在載入 Maps JavaScript API 程式碼時,將 region
參數加到 <script>
標記。
對於 Maps JavaScript API 應用程式的開發人員,我們建議一律設定 region
參數。設定 region
之後,各項服務 (例如 Places Autocomplete) 通常能提供更準確的結果。
此外,針對應用程式的代管主機所在國家/地區,您有責任套用正確的區域本地化設定,確保應用程式符合當地法律規定。
region
參數接受萬國碼 (Unicode) 區域子標記 ID。一般來說,該 ID 可一對一對應至國家/地區代碼頂層網域 (ccTLD)。大多數萬國碼 (Unicode) 區域 ID 與 ISO 3166-1 alpha-2 代碼相同,但有一些需要注意的例外情況。舉例來說,英國的 ccTLD 是「uk」(對應到網域 .co.uk
),而區域 ID 卻是「GB」。如需支援區域的相關資訊,請參閱 Google 地圖平台涵蓋範圍詳細資料。請試用這裡的示範,瞭解更新 region
參數時地圖上發生的變化。
舉例來說,以下指令碼標記針對英國將地圖本地化:
<script async
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async®ion=GB&callback=initMap">
</script>
下例顯示兩張地圖,其中一張根據 region
設為 US
(美國) 的值,將「Toledo」的位置編碼為「Toledo, Ohio」;另一張則根據 region
設為 ES
(西班牙) 的值,將結果調整成「Toledo, Spain」。
查看美國範例和西班牙範例。
本地化示範
設定地圖語言時,也必須考慮設定區域。以下示範可讓您以自己選擇的語言和區域載入地圖。
在全螢幕模式中查看這個示範。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-06 (世界標準時間)。
[null,null,["上次更新時間: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)."]]