处理错误
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
提出请求后,您可能会收到包含错误详细信息的响应。
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 坐标范围与常规地图图块相同,直至 5 级缩放。此时,最大值为 imageHeight
或 imagewidth
除以 tileHeight
或 tileWidth
。
forbidden
:
可能的原因:
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 地块功能许可名单中。
消息:Your request cannot be served. Please ensure the parameters and
request type are valid for your account and region.
如果项目与账单邮寄地址位于欧洲经济区 (EEA) 的结算账号相关联,则无法使用逼真 3D 地块。如需了解详情,请参阅针对 EEA 客户的 Map Tiles API 调整。
- 429:请求数过多
- 您的配额已用尽。请与 Google 支持团队联系,以提高您的配额。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):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."]]