问题描述
我注意到现代基于 html5 的地理位置总是询问用户你想与这个网站分享你的位置吗?".这很好,但我知道还有其他途径可以尝试确定棒球场的地理位置,而无需请求此许可.如果我记得,这些服务使用 ip 数据库来尝试跟踪地理定位信息并将其提供给网络应用程序.
Ive noticed that modern html5 based geolocation always asks the user "do you want to share your location with this website?". Which is fine, but I know there are other routes of trying to determine a ballpark geolocation without having to request this permission. If I recall, these services uses ip databases to try to track geolocaiton info and provide it to a web app.
因此,在我的网站中,我想在不请求地理定位许可的情况下对用户的邮政编码进行最佳猜测".最简单和/或最好的方法是什么?
So, in my website I would like to get a "best guess" at the user's zip code, without the geolocation permission being requested. What's the simplest and/or best method of doing this?
推荐答案
IP 地理位置不太准确,但您不需要用户许可.http://ipinfo.io API(这是我的服务)使它变得非常简单.这是一个 jQuery 示例:
IP geolocation is less accurate, but you don't need user permission for it. The http://ipinfo.io API (which is my service) makes it extremely simple. Here's a jQuery example:
$.get("http://ipinfo.io", function(response) {
console.log(response.city, response.region, response.country);
}, "jsonp");
此处提供更多详细信息.
这篇关于未经许可的地理定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!