處理錯誤
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
提出要求後,您可能會收到包含錯誤詳細資料的回應。
2D 圖塊和街景服務圖像
下表詳細列出使用 2D 圖塊和街景圖像時可能遇到的錯誤。
列出錯誤
下表詳細列出使用 Map Tiles API 時可能遇到的錯誤。
required
- 您的要求缺少網址參數。請注意,錯誤訊息會指出缺少哪個參數。
notFound
、invalid
x
、y
或 z
值超出範圍。
一般地圖圖塊的最大縮放等級取決於特定地圖圖塊,以及您要求的地圖選項。
如為一般地圖圖塊,x 座標必須在 [0, (2^zoom)-1] 範圍內。
如為一般地圖圖塊,y 座標必須在 [0, (2^(zoom-1))-1)] 範圍內。
街景圖塊的縮放比例必須介於 0 到 5 之間 (含首尾)。
對於街景服務圖塊,x 和 y 座標範圍與一般地圖圖塊相同,直到第五級縮放。此時,最大值為 imageHeight
或 imagewidth
除以 tileHeight
或 tileWidth
。
forbidden
:
可能原因:
要求缺少有效的 API 金鑰。
訊息:Your request cannot be served. Please ensure the parameters and
request type are valid for your account and region.
如果專案連結的帳單帳戶地址位於歐洲經濟區 (EEA),則無法使用 2D 衛星圖塊。詳情請參閱「Map Tiles API adjustments for EEA customers」。
expired
- 您的
session
權杖已過期。工作階段權杖的效期為建立時間起算的兩週。請注意,這項資訊可能會隨時變動,恕不另行通知。如果收到這則錯誤訊息,請按照「使用工作階段權杖」一文的說明,取得新的工作階段權杖。
badRequest
您的要求格式錯誤。常見原因包括:
quotaExceeded
、rateLimitExceeded
您的應用程式已超出允許的配額,或每秒查詢次數超出允許上限。
錯誤範例
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"errors": [
{
"message": "The request is missing a valid API key.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
重試要求
如果要求失敗並出現 quotaExceeded
和 rateLimitExceeded
,您應重試要求,避免大量用戶端嘗試快速連續重試要求,導致 Google 伺服器因要求中斷或大規模失敗而超載。也就是說,重試要求時,請使用指數輪詢。指數輪詢會強制您間隔一段時間再發出要求,讓伺服器有時間復原。
舉例來說,如果要求失敗,請在一秒後重試。但如果該嘗試也失敗,請在兩秒後再次重試要求。如果該要求也失敗,請在四秒後重試。因此,您只要將每次連續要求之間的時間間隔加倍,就能有效分散要求。
3D 圖塊
您是透過負責處理伺服器錯誤的算繪器存取擬真圖塊,因此可能不會發現 Google 伺服器發生錯誤。
圖塊轉譯器錯誤
舉例來說,發生伺服器錯誤時,CesiumJS 轉譯器通常會無聲無息地失敗,導致當機、空白畫面,或是特定圖塊無法載入。
您用來偵錯伺服器錯誤的技術,取決於您使用的特定轉譯器。如果是以瀏覽器為基礎的算繪器 (例如 CesiumJS),您可以使用大多數瀏覽器內建的工具檢查網路流量。舉例來說,您可以使用 Chrome 開發人員工具。
常見錯誤
以下列出您可能會遇到的常見錯誤,並提供詳細資訊。
- 400:引數無效
- API 金鑰、查詢參數、圖塊/圖塊集 ID 無效,或是工作階段權杖已過期。
- 400:無效值
- 確認發出
createSessionToken
要求的 mapType 與後續圖塊端點中使用的 mapType
相符。舉例來說,streetview
工作階段符記無法用於要求 roadmap
圖塊。
403:權限遭拒
可能原因:
API 金鑰遺失、SSL 連線遺失,或是 API 金鑰尚未加入 3D 圖塊的允許清單。請與 Google 支援團隊聯絡,並提供專案 ID,要求將您加入 Map Tiles API 的 3D Tiles 功能許可清單。
訊息:Your request cannot be served. Please ensure the parameters and
request type are valid for your account and region.
如果專案連結的帳單帳戶地址位於歐洲經濟區,就無法使用擬真 3D 圖塊。詳情請參閱「Map Tiles API adjustments for EEA customers」。
- 429:要求數量過多
- 配額已用盡。如要提高配額,請與 Google 支援團隊聯絡。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eRequests for 2D Tiles and Street View imagery may result in errors such as \u003ccode\u003erequired\u003c/code\u003e, \u003ccode\u003enotFound\u003c/code\u003e, \u003ccode\u003einvalid\u003c/code\u003e, \u003ccode\u003eforbidden\u003c/code\u003e, \u003ccode\u003eexpired\u003c/code\u003e, \u003ccode\u003ebadRequest\u003c/code\u003e, \u003ccode\u003equotaExceeded\u003c/code\u003e, or \u003ccode\u003erateLimitExceeded\u003c/code\u003e indicating issues with parameters, API keys, or quota limits.\u003c/p\u003e\n"],["\u003cp\u003eWhen retrying requests that failed due to \u003ccode\u003equotaExceeded\u003c/code\u003e or \u003ccode\u003erateLimitExceeded\u003c/code\u003e, it's crucial to implement exponential backoff to avoid overwhelming Google servers.\u003c/p\u003e\n"],["\u003cp\u003e3D Tiles errors are often handled by the renderer, requiring debugging techniques like inspecting network traffic using browser developer tools.\u003c/p\u003e\n"],["\u003cp\u003eCommon 3D Tiles errors include 400 (Invalid argument), 403 (Permission denied), and 429 (Too many requests), which can be addressed by verifying API keys, SSL connections, allowlisting, or adjusting quotas.\u003c/p\u003e\n"]]],["Upon encountering errors when using Map Tiles API, common issues include missing URL parameters (`required`), out-of-range coordinates (`notFound`, `invalid`), an invalid API key (`forbidden`), or an expired session token (`expired`). Other errors involve malformed requests (`badRequest`) or exceeding usage limits (`quotaExceeded`, `rateLimitExceeded`). When rate limiting occurs, implement exponential backoff when retrying requests. 3D Tiles errors may be handled by the renderer and include issues like invalid keys, missing API key, or exceeded quota.\n"],null,["# Handling errors\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google\n| Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. [Learn more](/maps/comms/eea/faq). In addition, certain content from the Map Tiles API will no longer be returned. [Learn more](/maps/comms/eea/map-tiles).\n\nAfter you make a request, you might receive a response that contains error\ndetails.\n\n2D Tiles and Street View imagery\n--------------------------------\n\nThe following list details the errors that you might encounter when using 2D\nTiles and Street View imagery.\n\n### Error listing\n\nThe following list details the errors you might encounter when using the\nMap Tiles API.\n\n`required`\n: Your request is missing a URL parameter. Note that the error message indicates\n which parameter is missing.\n\n`notFound`, `invalid`\n\n: Your \u003cvar class=\"apiparam\" translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ex\u003c/code\u003e\u003c/var\u003e, \u003cvar class=\"apiparam\" translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ey\u003c/code\u003e\u003c/var\u003e, or\n \u003cvar class=\"apiparam\" translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ez\u003c/code\u003e\u003c/var\u003e values are out of range.\n\n - For regular map tiles, the maximum zoom level depends on the particular\n map tile, and on the map options that you requested.\n\n - For regular map tiles, the x coordinate must be in the range\n \\[0, (2\\^zoom)-1\\].\n\n - For regular map tiles, the y coordinate must be in the range\n \\[0, (2\\^(zoom-1))-1\\].\n\n - For Street View Tiles, zoom must be between zero and five, inclusive.\n\n - For Street View Tiles, the x and y coordinate ranges are the same as\n for regular map tiles, until level five zoom. At that point, the maximum\n values are `imageHeight` or `imagewidth` divided by `tileHeight` or\n `tileWidth`.\n\n`forbidden`:\n\nPossible causes:\n\n- The request is missing a valid API key.\n\n- Message: `Your request cannot be served. Please ensure the parameters and\n request type are valid for your account and region.`\n\n 2D satellite tiles are not available in projects that are linked to a\n billing account with a European Economic Area (EEA) address. For more\n information, see [Map Tiles API adjustments for EEA\n customers](/maps/comms/eea/map-tiles#adjustments).\n\n`expired`\n: Your `session` token has expired. A session token is valid for\n two weeks from its creation time. Note that this might change\n without notice. If you receive this error, then you must get a new session\n token, as described in\n [Use session tokens](/maps/documentation/tile/session_tokens).\n\n`badRequest`\n\n: Your request was malformed. Common reason for this include:\n\n - You specified a `terrain` map type without including a `roadmap` layer.\n\n - You included a `styles` array for a non-roadmap map type.\n\n - You sent a lat/lng value, as well as a panorama ID in a Street View metadata\n request.\n\n`quotaExceeded`, `rateLimitExceeded`\n\n: Your application has exceeded its allowed quota, or it exceeded it allowed\n number of queries per second.\n\n### Example error\n\n {\n \"error\": {\n \"code\": 403,\n \"message\": \"The request is missing a valid API key.\",\n \"errors\": [\n {\n \"message\": \"The request is missing a valid API key.\",\n \"domain\": \"global\",\n \"reason\": \"forbidden\"\n }\n ],\n \"status\": \"PERMISSION_DENIED\"\n }\n }\n\n### Retrying requests\n\nWhen requests fail with `quotaExceeded` and `rateLimitExceeded`, you should\nretry your request in such as way that broken requests or wide-scale failures\ndon't flood Goodle servers---as many clients attempt to retry requests in quick\nsuccession. This means using\n[exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff)\nwhen you retry your requests. Exponential backoff forces you to spread your\nrequests out in time, to give the server time to recover.\n\nFor example, if a request fails, then retry again after one second. But if that\nattempt fails as well, then retry your request again after two seconds. If that\nrequest also fails, then try again after four seconds. So you effectively spread\neach successive request out by simply doubling the length of time between them.\n\n3D Tiles\n--------\n\nErrors from Google's server might not be obvious to you because you access\nphotorealistic tiles through a renderer, which is responsible for handling\nserver errors.\n\n### Tile renderer errors\n\nFor example, the CesiumJS renderer usually fails silently when server errors\noccur, which can result in anything from crashes, blank screens, to specific\ntiles not loading.\n\nThe technique that you use to debug server errors will depend on the particular\nrenderer you use. For browser-based renderers like CesiumJS, you can inspect\nthe network traffic with tools built into most browsers. For example, you can\nuse\n[Chrome DevTools](https://developer.chrome.com/docs/devtools/).\n\n### Common errors\n\nThe following list contains details about the most common errors that you might\nencounter.\n\n400: Invalid argument\n: Invalid API keys, query parameters, tile/tileset IDs, or an expired session\n token.\n\n400: Invalid Value\n: Make sure that the mapType with which the `createSessionToken` request was\n made matches the `mapType` used in the subsequent tile endpoint. For example, a\n `streetview` session token cannot be used to request a `roadmap` tile.\n\n**403: Permission denied**\n\nPossible causes:\n\n- Missing API key, missing SSL connection, or your API key has not been added\n to the allowlist for 3D Tiles. Contact [Google\n Support](/maps/support#contact-maps-support) with your project ID to get\n added to the allowlist for the 3D Tiles functionality of the\n Map Tiles API.\n\n- Message: `Your request cannot be served. Please ensure the parameters and\n request type are valid for your account and region.`\n\n Photorealistic 3D tiles are not available in projects that are linked to a\n billing account with a European Economic Area (EEA) address. For more\n information, see [Map Tiles API adjustments for EEA\n customers](/maps/comms/eea/map-tiles#adjustments).\n\n429: Too many requests\n: Your quota is exhausted. Contact\n [Google Support](/maps/support#contact-maps-support) to increase your quota."]]