使用 Google 地图进行区域偏差

发布于 2024-09-29 18:28:42 字数 326 浏览 4 评论 0原文

我的用户可能位于世界任何地方,他们都会看到一个文本框,他们可以在其中输入他们的地址。在大多数情况下,我假设他们实际上与他们输入的地址位于同一个国家/地区。

我想通过区域偏差来帮助 Google Map API 做出更好的猜测一个>。有没有办法告诉 Google 提出请求的地区存在偏见?或者,当我进行网络服务调用时,如何将该信息提供给 Google(例如,将 IP 地址转换为国家/地区信息)?

谢谢。

My users, who may be located anywhere in the world, will be presented with a text box wherein they can enter their address. In most cases, I assume they will physically be in the same country as whatever address they are typing.

I'd like to help Google Map API make better guesses by doing region biasing. Is there a way to tell Google to region bias from where the request is being made? Or how can I give that information to Google when I make the web service call (e.g. convert IP address to country information)?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹过旳痕迹 2024-10-06 18:28:42

上次我检查时,客户端和服务器端 Google Geocoder 的“区域偏差”都不可靠。查看去年四月的这篇文章(现在再次测试,问题仍然存在):

我发现最可靠的方法是将国家/地区附加在地址末尾。因此,如果用户位于英国,并输入“伦敦牛津街”,您需要将“, UK”附加到地址以进行地理编码。

要获取用户所在的国家/地区,有很多解决方案。您可以使用 Geolocation API按照 @You 在其他答案中的建议 ,或者您可能想要使用第三方 IP 定位服务。您可能需要查看 MaxMind GeoLite City 服务,该服务是免费的,据报道 99.5%在国家层面上准确。

The last time I checked, the "region bias" for both the client-side and the server-side Google Geocoder was not reliable. Check out this post from last April (tested again right now, and the issue persists):

The most reliable way that I found is to append the country at the end of the address. Therefore if the user is located in the UK, and types "Oxford Street London", you'd attach ", UK" to the address for geocoding.

To get the country of the user, there are quite a few solutions. You could use the Geolocation API as @You suggested in the other answer, or you may want to use a third party IP-to-location service. You may want to check out MaxMind GeoLite City service, which is free, and is reportedly 99.5% accurate on a country level.

拔了角的鹿 2024-10-06 18:28:42

在现代浏览器中,您可以使用 HTML5 地理定位 API,如深入了解 HTML5 中所述。这假设有客户端支持并且您在客户端发出请求。对于服务器端(或后备)解决方案,您可以尝试类似 PHP Geo IP 函数

In modern browsers you can use the HTML5 Geolocation API as described in Dive Into HTML5. This assumes client-side support and that you're making the requests client-side. For a server-side (or fallback) solution, you could try something like the PHP Geo IP functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文