排查问题
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
以下是一些关于排查常见问题的提示。
为什么精确度半径非常大?
如果地理定位响应在准确度字段中显示的值非常高,则服务可能正在根据请求 IP 进行地理定位,而不是根据 Wi-Fi 热点或手机基站进行地理定位。如果服务无法识别任何基站或接入点,可能会出现此类响应。
如需确认服务无法对您的接入点进行地理定位,请在请求中将 considerIp
设置为 false。如果响应为 404,则表示您已确认无法对 wifiAccessPoints 和 cellTowers 对象进行地理定位。
如何排查回答错误?
如果您的请求生成错误,系统会返回标准格式的错误响应正文,并将 HTTP 状态代码设置为错误状态。
错误响应包含一个对象,该对象包含一个具有以下键的错误对象:
code
:与响应的 HTTP 状态相同。
message
:简短的错误说明。
errors
:发生错误的列表。每个错误都包含错误类型(原因)的标识符和简短说明(消息)。
例如,发送无效的 JSON 会返回以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error",
}
],
"code": 400,
"message": "Parse Error"
}
}
如需进行其他测试,您可以使用以下 SDK 和 API 从设备收集信息:
错误说明
以下是您可能会遇到的错误以及相关说明。
原因 |
网域 |
HTTP 状态代码 |
说明 |
dailyLimitExceeded |
usageLimits |
403 |
您已超出每日限额。 |
keyInvalid |
usageLimits |
400 |
您的 API 密钥对 Geolocation API 无效。请务必包含整个密钥,并确保您已购买该 API 或已启用结算功能并激活该 API,以便免费获得配额。 |
userRateLimitExceeded |
usageLimits |
403 |
您已超出在 Google Cloud 控制台中配置的请求限制。
此限制通常设置为每天请求数、每 100 秒请求数和每个用户每 100 秒请求数。您应配置限额,以防止单个或少数用户耗尽每日配额,同时仍允许所有用户合理访问。
如需配置这些限制,请参阅设置 API 用量上限。
|
notFound |
geolocation |
404 |
请求有效,但未返回任何结果。 |
parseError |
global |
400 |
请求正文不是有效的 JSON。如需详细了解每个字段,请参阅请求正文部分。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe Geolocation API uses IP addresses, WiFi points, and cell towers to determine location, with large accuracy radius often indicating IP-based geolocation.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting involves examining the error response, which includes an error code, message, and a list of errors with reasons and descriptions.\u003c/p\u003e\n"],["\u003cp\u003eYou can gather additional testing information from devices using the Android Location APIs, Places SDK for Android and iOS.\u003c/p\u003e\n"],["\u003cp\u003ePossible errors include exceeding daily or user request limits, using an invalid API key, and requests returning no results despite being valid.\u003c/p\u003e\n"]]],["If a large accuracy radius is shown, the service may be using the request IP instead of cell towers or WiFi. Test by setting `considerIp` to false; a 404 response confirms no access points were found. Error responses include a `code` (HTTP status), `message`, and an `errors` list with `reason` and `message`. Common errors include `dailyLimitExceeded` (403), `keyInvalid` (400), `userRateLimitExceeded` (403), `notFound` (404), and `parseError` (400) due to invalid JSON.\n"],null,["# Troubleshoot\n\nHere are some tips on troubleshooting common issues.\n\nWhy is the accuracy radius very large?\n--------------------------------------\n\nIf your Geolocation response shows a very high value in the accuracy field, the\nservice may be geolocating based on the request IP, instead of WiFi points or\ncell towers. These kinds of responses can happen if the service does not\nrecognize any cell towers or access points.\n\nTo confirm that the service could not geolocate your access points, set\n`considerIp` to false in your request. If the response is a 404, you've\nconfirmed that your wifiAccessPoints and cellTowers objects could not be geolocated.\n\nHow do I troubleshoot a response error?\n---------------------------------------\n\nIf your request generates an error, the system returns a standard format error\nresponse body and sets the HTTP status code to an error status.\n\nThe error response contains an object with a single error object with the\nfollowing keys:\n\n- `code`: This is the same as the HTTP status of the response.\n- `message`: A short description of the error.\n- `errors`: A list of errors that occurred. Each error contains an identifier for the type of error (the reason) and a short description (the message).\n\nFor example, sending invalid JSON returns the following error: \n\n {\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"global\",\n \"reason\": \"parseError\",\n \"message\": \"Parse Error\",\n }\n ],\n \"code\": 400,\n \"message\": \"Parse Error\"\n }\n }\n\nGather testing information from devices\n---------------------------------------\n\nFor additional testing, you can gather information from your device using the\nfollowing SDKs and APIs:\n\n- **Android devices** : Go to [Places SDK for Android](/maps/documentation/places/android-sdk/current-place), and [Android\n Location APIs](https://developer.android.com/training/location/index.html).\n\n- **iOS devices** : Go to [Places SDK for iOS](/maps/documentation/places/ios-sdk/current-place).\n\nError descriptions\n------------------\n\nHere are the possible errors you might encounter with descriptions.\n\n| Reason | Domain | HTTP Status Code | Description |\n|-------------------------|---------------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dailyLimitExceeded` | `usageLimits` | 403 | You have exceeded your [daily limit](/maps/documentation/geolocation/usage-and-billing#other-usage-limits). |\n| `keyInvalid` | `usageLimits` | 400 | Your API key is not valid for the Geolocation API. Be sure to include the entire key, and that you've either purchased the API or have [enabled billing and activated the API](/maps/documentation/geolocation/get-api-key) to obtain the quota at no charge. |\n| `userRateLimitExceeded` | `usageLimits` | 403 | You have exceeded the request limit that you configured in the Google Cloud console. This limit is typically set as requests per day, requests per 100 seconds, and requests per 100 seconds per user. You should configure your limit to prevent a single or small group of users from exhausting your daily quota, while still allowing reasonable access to all users. See [Capping API Usage](https://cloud.google.com/apis/docs/capping-api-usage) to configure these limits. |\n| `notFound` | `geolocation` | 404 | The request was valid, but no results were returned. |\n| `parseError` | `global` | 400 | The request body is not valid JSON. Refer to the [Request Body](/maps/documentation/geolocation/requests-geolocation#body) section for details on each field. |"]]