Câu hỏi thường gặp về mã hóa địa lý
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Phần Câu hỏi thường gặp này đề cập đến các câu hỏi dành riêng cho API Địa chỉ.
Hãy tham khảo Câu hỏi thường gặp về Nền tảng Google Maps để biết các câu hỏi phổ biến về tất cả Nền tảng Google Maps. Xem thêm nội dung Các phương pháp hay nhất khi mã hoá địa lý địa chỉ.
Khắc phục sự cố
Khắc phục sự cố
-
Tôi nhận được nhiều truy vấn trả về ZERO_RESULTS hơn với trình dịch địa lý. Nội dung có vấn đề gì?
-
Trong trình định vị địa lý, các truy vấn không rõ ràng, không đầy đủ và định dạng không chính xác, chẳng hạn như địa chỉ bị sai chính tả hoặc không tồn tại, có xu hướng tạo ra ZERO_RESULTS.
Nếu không tìm thấy địa chỉ, bạn nên sử dụng ZERO_RESULTS thay vì kết quả một phần (ví dụ: chỉ trả về vùng ngoại ô thay vì địa chỉ).
Nếu ứng dụng của bạn xử lý địa chỉ do người dùng nhập, thì tính năng Tự động hoàn thành địa điểm trong API Địa điểm có thể mang lại kết quả chất lượng cao hơn.
Tính năng Tự động hoàn thành địa điểm cho phép người dùng chọn trong một tập hợp kết quả dựa trên nội dung họ đã nhập. Tính năng này cho phép người dùng chọn giữa các kết quả có tên tương tự nhau và điều chỉnh cụm từ tìm kiếm nếu họ đánh sai chính tả địa chỉ.
Nếu ứng dụng của bạn xử lý các truy vấn không rõ ràng hoặc không đầy đủ hoặc các truy vấn có thể chứa lỗi, bạn nên sử dụng tính năng Tự động hoàn thành địa điểm trong API Địa điểm thay vì bộ mã hoá địa lý chuyển tiếp có trong API Mã hoá địa lý. Để biết thêm thông tin, hãy xem bài viết
Các phương pháp hay nhất khi mã hoá địa lý địa chỉ và
Mã hoá địa lý địa chỉ trong bài đăng trên blog về API Maps của Google.
-
Tôi cần phản hồi nhanh và trình mã hoá địa lý quá chậm đối với ứng dụng của tôi. Tôi có thể sử dụng tính năng nào để nhận được phản hồi nhanh hơn?
-
Các ứng dụng phản hồi dữ liệu đầu vào của người dùng và do đó rất nhạy cảm với độ trễ nên sử dụng tính năng Tự động hoàn thành địa điểm trong API Địa điểm (cũng có trong JavaScript, Android hoặc iOS) thay vì mã hoá địa lý địa chỉ.
Tính năng Tự động hoàn thành địa điểm được tối ưu hoá để sử dụng một cách tương tác, do đó có độ trễ rất thấp.
Tính năng mã hoá địa lý địa chỉ trong API Mã hoá địa lý được tối ưu hoá để sử dụng với các địa chỉ đầy đủ, rõ ràng, được định dạng tốt, chẳng hạn như địa chỉ giao hàng được nhập vào các biểu mẫu trực tuyến, do đó có độ trễ cao hơn so với tính năng Tự động hoàn thành địa điểm. Trình định mã địa lý chuyển tiếp có phạm vi phủ sóng lớn hơn và chất lượng kết quả tốt hơn, nhưng có độ trễ cao hơn một chút.
-
Làm cách nào để giảm độ trễ trên API chỉ đường (Cũ) và API Distance Matrix (Cũ)?
-
Thay vì địa chỉ, hãy sử dụng mã nhận dạng địa điểm để chỉ định điểm trung gian, điểm xuất phát và điểm đến. Tốt nhất là bạn nên lấy mã địa điểm từ tính năng Tự động hoàn thành địa điểm trong API Địa điểm hoặc thư viện Địa điểm trong API Maps JavaScript. Xem thêm thông tin về tuỳ chọn
placeIdOnly
. Bạn có thể sử dụng tuỳ chọn này để giảm chi phí của tính năng Tự động hoàn thành địa điểm.
Khi bạn truy vấn API Chỉ đường (Cũ) hoặc API Ma trận khoảng cách (Cũ) bằng một chuỗi địa chỉ thay vì mã địa điểm hoặc latlng, các API này sẽ sử dụng cùng một phần phụ trợ như API Mã hoá địa lý để chuyển đổi địa chỉ đó thành mã địa điểm trước khi tính toán đường đi. Tính năng Tự động hoàn thành địa điểm nhanh hơn so với việc mã hoá địa lý địa chỉ. Đối với các ứng dụng sử dụng API Chỉ đường (Cũ) hoặc API Distance Matrix (Cũ) trong các tình huống nhạy cảm với độ trễ cao, chẳng hạn như phản hồi dữ liệu đầu vào của người dùng, bạn nên sử dụng tính năng Tự động hoàn thành địa điểm để lấy mã địa điểm tương ứng với các địa chỉ đó và truyền mã địa điểm đó đến API Chỉ đường (Cũ) hoặc API Distance Matrix (Cũ).
Phương pháp này giúp giảm đáng kể độ trễ. Hãy xem tài liệu của chúng tôi để biết
ví dụ về cách sử dụng tính năng Tự động hoàn thành địa điểm cùng với thông tin chỉ đường.
-
Làm cách nào để báo cáo lỗi trong trình dịch địa lý?
-
Nếu bạn có
báo cáo lỗi hoặc
yêu cầu về tính năng cho dịch vụ chuyển tiếp trình dịch địa lý, hãy cho chúng tôi biết bằng cách sử dụng
công cụ theo dõi lỗi công khai của chúng tôi.
-
Trình dịch địa lý không tạo ra kết quả tốt cho trường hợp sử dụng của tôi. Những dịch vụ hỗ trợ nào có sẵn?
-
Hãy cho chúng tôi biết bằng cách sử dụng
công cụ theo dõi lỗi công khai, chia sẻ một vài cụm từ tìm kiếm cụ thể để chúng tôi có thể điều tra xem có lỗi hoặc vấn đề hệ thống nào gây ra vấn đề về chất lượng kết quả hay không, hoặc chúng tôi có thể thay đổi hướng dẫn các phương pháp hay nhất để giúp nhà phát triển đạt được kết quả tốt hơn hay không.
-
Làm cách nào để có được kết quả tốt nhất với trình định vị địa lý bằng cách sử dụng tính năng lọc thành phần?
-
Trong trình định vị địa lý, tính năng
lọc thành phần chỉ thực thi các quy định hạn chế về postal_code
và
country
. Các ví dụ sau đây minh hoạ cách tốt nhất để sử dụng tính năng lọc thành phần, tuỳ thuộc vào kết quả bạn cần. Trong URL yêu cầu mẫu, hãy nhớ thay thế "YOUR_API_KEY" bằng khoá API thực tế của bạn.
- Để hạn chế mã bưu chính ở một quốc gia cụ thể, hãy nhớ chỉ định quy định hạn chế về quốc gia bằng mã quốc gia ISO 3166-2.
Ví dụ:
components=country:CH|postal_code:8000
trả về "8000 Zürich, Thuỵ Sĩ".
https://maps.googleapis.com/maps/api/geocode/json?components=country:CH%7Cpostal_code:8000&key=YOUR_API_KEY
- Để hạn chế cụm từ tìm kiếm ở một quốc gia cụ thể, hãy nhớ chỉ định hạn chế về quốc gia bằng cách sử dụng mã quốc gia ISO 3166-2. Tên quốc gia và các từ viết tắt khác có thể không mang lại kết quả giống như mã quốc gia.
Ví dụ:
- Việc mã hoá địa lý cho
components=country:FRA|locality:gallus
sẽ trả về tiểu khu Gallus ở Frankfurt am Main, Đức. Lý do là mã quốc gia gồm 3 chữ cái cho Pháp (FRA) không được hỗ trợ, do đó, kết quả ở bất kỳ quốc gia nào đều được chấp nhận và kết quả ở Frankfurt phù hợp hơn bất kỳ kết quả nào ở Pháp.
https://maps.googleapis.com/maps/api/geocode/json?components=country:FRA%7Clocality:gallus&key=YOUR_API_KEY
- API Địa chỉ được mã hoá địa lý không nhất thiết phải trả về nhiều kết quả cho các truy vấn không rõ ràng. Các truy vấn như vậy sẽ được tính năng Tự động hoàn thành địa điểm trả lời chính xác hơn.
Ví dụ:
- Tính năng mã hoá địa lý cho
components=country:US|locality:madrid
trả về "Madrid, NM 87010, USA" nhưng không có thành phố nào khác ở Hoa Kỳ có tên là "Madrid".
https://maps.googleapis.com/maps/api/geocode/json?components=country:US%7Clocality:madrid&key=YOUR_API_KEY
- Việc sử dụng tính năng Tự động hoàn thành địa điểm cho
input=madrid&components=country:us&types=(regions)
, đồng thời chỉ định khung nhìn bằng location
và radius
để
châm biếm kết quả vị trí, sẽ tạo ra một phản hồi với một số thành phố ở Hoa Kỳ có tên là "Madrid".
https://maps.googleapis.com/maps/api/place/autocomplete/json?location=37.386052,-122.083851&radius=10000&input=madrid&components=country:us&types=(regions)&key=YOUR_API_KEY
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThis FAQ addresses questions about the Geocoding API; for general Google Maps Platform questions, refer to the Google Maps Platform FAQ.\u003c/p\u003e\n"],["\u003cp\u003eFor applications with user input and latency sensitivity, Google recommends using Place Autocomplete instead of address geocoding for better results and speed.\u003c/p\u003e\n"],["\u003cp\u003eTo improve latency with the Directions or Distance Matrix APIs, use place IDs obtained from Place Autocomplete instead of addresses.\u003c/p\u003e\n"],["\u003cp\u003eYou can report bugs or request features for the Geocoding API through the public issue tracker.\u003c/p\u003e\n"],["\u003cp\u003eComponent filtering in the Geocoding API is primarily used to restrict results by country and postal code.\u003c/p\u003e\n"]]],[],null,["This FAQ covers questions specific to the Geocoding API.\nRefer to the [Google Maps Platform FAQ](/maps/faq) for questions\ncommon to all Google Maps Platform. See also\n[Best Practices When Geocoding Addresses](/maps/documentation/geocoding/best-practices).\n\nTroubleshooting\n\n- [I'm getting more queries that return ZERO_RESULTS with the geocoder. What's going on?](#trbl-zero-results)\n- [I need fast responses, and the geocoder is too slow for my application. What can\n I use for faster responses?](#trbl-slow)\n- [How can I mitigate the latency on the Directions API (Legacy) and\n Distance Matrix API (Legacy)?](#trbl-latency)\n- [How do I report bugs in the geocoder?](#trbl-report-bug)\n- [The geocoder isn't producing good results for my use case. What help is available?](#trbl-help)\n- [How do I get the best results with the geocoder using component filtering?](#trbl-component-filtering)\n\nTroubleshooting\n\n\nI'm getting more queries that return ZERO_RESULTS with the geocoder. What's going on?\n\n: In the geocoder, ambiguous, incomplete and badly formatted queries, such as\n misspelled or nonexistent addresses, are prone to produce ZERO_RESULTS.\n If the address cannot be found, ZERO_RESULTS is preferable to a partial\n result (for example returning only the suburb in lieu of an address).\n\n If your application deals with user input of addresses, the\n [Place Autocomplete](/maps/documentation/places/web-service/autocomplete) feature\n in the Places API may produce better quality results.\n Place Autocomplete allows users to select from a set of results based on what\n they've typed, which allows users to choose between similarly named results,\n and to adjust their query if they misspell an address.\n\n If you have an application dealing with ambiguous or incomplete queries or queries\n that may contain errors, we recommend you use the\n [Place Autocomplete](/maps/documentation/places/web-service/autocomplete) feature\n in the Places API rather than the forward geocoder\n available in the Geocoding API. For more details, see\n [Best Practices When Geocoding Addresses](/maps/documentation/geocoding/best-practices) and the\n [Address Geocoding in the Google Maps APIs blog post](https://mapsplatform.google.com/resources/blog/address-geocoding-in-google-maps-apis/).\n\n\nI need fast responses, and the geocoder is too slow for my application. What can\nI use for faster responses?\n\n: We recommend that applications that respond to user input, and therefore are highly\n latency-sensitive, use the [Place Autocomplete](/maps/documentation/places/web-service/autocomplete)\n feature in the Places API (also available in\n [JavaScript](/maps/documentation/javascript/places-autocomplete),\n [Android](/maps/documentation/places/android-sdk/autocomplete), or\n [iOS](/maps/documentation/places/ios-sdk/autocomplete)) rather than address geocoding.\n Place Autocomplete is optimized to be used interactively, and thus has very low latency.\n\n Address geocoding in the Geocoding API is optimized for use with\n complete, unambiguous, well formatted addresses, such as delivery addresses entered into\n online forms, and thus has higher latency than Place Autocomplete. The forward geocoder\n has greater coverage and better result quality, but with somewhat higher latency.\n\n\nHow can I mitigate the latency on the Directions API (Legacy) and\nDistance Matrix API (Legacy)?\n\n: Instead of addresses, use [place IDs](/maps/documentation/places/web-service/place-id) to\n specify waypoints, origin, and destination. Place IDs are best obtained from the\n [Place Autocomplete](/maps/documentation/places/web-service/autocomplete)\n feature in the Places API or the\n [Places library](/maps/documentation/javascript/places-autocomplete) in the\n Maps JavaScript API. See also the information on the\n [`placeIdOnly`](/maps/documentation/javascript/places-autocomplete#placeidonly) option, which can be used to reduce the cost of\n Place Autocomplete.\n\n When the Directions API (Legacy) or Distance Matrix API (Legacy)\n is queried with an address string rather than a place ID or latlng, they use the same\n backend as the Geocoding API to convert that address into a\n place ID prior to calculating directions. Place Autocomplete is faster than address\n geocoding. For applications that use the Directions API (Legacy) or\n Distance Matrix API (Legacy) in highly latency-sensitive situations, such as\n responding to user input, we recommended you use Place Autocomplete to get the place IDs\n corresponding to those addresses, and pass the place IDs to the\n Directions API (Legacy) or Distance Matrix API (Legacy).\n This approach reduces latency significantly. See our documentation for an\n [example of how to use Place Autocomplete with directions](/maps/documentation/javascript/examples/places-autocomplete-directions).\n\n\nHow do I report bugs in the geocoder?\n\n: If you have any\n [bug reports](https://issuetracker.google.com/savedsearches/558483) or\n [feature requests](https://issuetracker.google.com/issues/new?component=188871&template=788905) for the forward geocoder service, let us know using our public\n [issue tracker](https://issuetracker.google.com/issues/new?component=188871&template=788906).\n\n\nThe geocoder isn't producing good results for my use case. What help is available?\n\n: Let us know using our public\n [issue tracker](https://issuetracker.google.com/savedsearches/558483), sharing a few specific queries, so we can investigate to\n see if there are any bugs or systemic issues causing problems with result\n quality, or if there are any changes we can make to the\n [best practices guide](/maps/documentation/geocoding/best-practices)\n to help developers get better results.\n\n\nHow do I get the best results with the geocoder using component filtering?\n\n: In the geocoder, [component filtering](/maps/documentation/geocoding/overview#component-filtering) enforces only `postal_code` and\n `country` restrictions. The following examples illustrate how best to use component\n filtering, depending on the results you need. In the sample request URLs, be sure to\n replace \\`YOUR_API_KEY\\` with your actual API key.\n\n - To restrict postal codes to a specific country, be sure to specify the country restriction using an [ISO 3166-2 country code](https://en.wikipedia.org/wiki/ISO_3166-2). For example: `components=country:CH|postal_code:8000` returns \"8000 Zürich, Switzerland\". \n\n ```scdoc\n https://maps.googleapis.com/maps/api/geocode/json?components=country:CH%7Cpostal_code:8000&key=YOUR_API_KEY\n ```\n - To restrict queries to a specific country, be sure to specify the country restriction using an [ISO 3166-2 country code](https://en.wikipedia.org/wiki/ISO_3166-2). Country names and other abbreviations may not produce the same results as country codes.\n\n Examples:\n - Geocoding for `components=country:FRA|locality:gallus` returns the sublocality of Gallus in Frankfurt am Main, Germany. This is because the 3-letter country code for France (FRA) isn't supported, thus results in any country are allowed and the result in Frankfurt is a better fit than anything in France. \n\n ```scdoc\n https://maps.googleapis.com/maps/api/geocode/json?components=country:FRA%7Clocality:gallus&key=YOUR_API_KEY\n ```\n - Geocoding API won't necessarily return multiple results for ambiguous queries. Such queries are better answered by the Place Autocomplete. Examples:\n\n - Geocoding for `components=country:US|locality:madrid` returns \"Madrid, NM 87010, USA\" but none of the other cities in the USA named \"Madrid\". \n\n ```scdoc\n https://maps.googleapis.com/maps/api/geocode/json?components=country:US%7Clocality:madrid&key=YOUR_API_KEY\n ```\n - Using Place Autocomplete for `input=madrid&components=country:us&types=(regions)`, and also specifying a viewport using `location` and `radius` to [bias the location results](/maps/documentation/places/web-service/autocomplete#location_biasing), generates a response with several cities in the USA named \"Madrid\". \n\n ```carbon\n https://maps.googleapis.com/maps/api/place/autocomplete/json?location=37.386052,-122.083851&radius=10000&input=madrid&components=country:us&types=(regions)&key=YOUR_API_KEY\n ```"]]