問題描述
我注意到現代基于 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");
此處提供更多詳細信息.
這篇關于未經許可的地理定位的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!