- compare users IP address to a database of longitude/latitude or use an online API for this purpose; 将用户的IP地址与经度/纬度数据库进行比较,或为此目的使用在线API;
- or use a W3C HTML Geolocation API. 或使用W3C HTML Geolocation API。
Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. Although W3C Geolocation API doesn't guarantee that the API returns the device's actual location it will try it's best for sure.
位置信息的常见来源包括全球定位系统(GPS)和从网络信号(例如IP地址,RFID,WiFi和蓝牙MAC地址,GSM / CDMA小区ID以及用户输入)推断出的位置。 尽管W3C Geolocation API不能保证API返回设备的实际位置,但它会尽力确保最佳状态。
But it is more complicated to implement and it will require user to explicitly allow to use his location data:
但是实现起来更加复杂,并且需要用户明确允许使用其位置数据:
最可靠的IP地理位置API列表 (List of the most reliable IP Geolocation APIs )
IPData.co
IPData.co
API Key: Required
API**:必填
API Latency: 65ms
API延迟:65ms
Their smallest plan is $10 a month for 2500 requests daily or 75,000 requests a month.
他们最小的计划是每月$ 10,每天2500个请求,或者每月75,000个请求。
Maxmind.com
Maxmind.com
API Key: Required
API**:必填
API Latency: 44ms
API延迟:44毫秒
For basic city level geolocation via the City endpoint, it'll cost $400 per million calls or $0.0004 per request.
对于通过City端点进行的基本城市级别的地理位置定位,每百万个呼叫费用为400美元,每个请求的费用为0.0004美元。
IPInfo.io
IPInfo.io
API Key: Not Required
API**:不需要
API Latency: 165ms
API延迟:165ms
Their Basic Plan including 250,000 requests a month for a $49 monthly.
他们的基本计划包括每月250,000个请求,每月49美元。
ipapi.com
ipapi.com
API Key: Not Required
API**:不需要
It's free for small projects up to 10,000 requests per month.
对于每月最多10,000个请求的小型项目,它是免费的。
ipapi.co
ipapi.co
API Key: Not Required
API**:不需要
API Latency: 270ms
API延迟:270毫秒
It's free up to 1000 requests a day, than it'll cost starting from $15 monthly depending from a daily volume of requests.
它每天最多免费提供1000个请求,其费用从每月15美元起,具体取决于每天的请求量。
db-ip.com
db-ip.com
API Key: Required
API**:必填
API Latency: 225ms
API延迟:225ms
It'll cost from €15.90 for 50,000 requests daily
每天50,000个请求的费用为€15.90 ipwhois.ioipwhois.io
API Key: Not Required
API**:不需要
API Latency: 75ms
API延迟:75毫秒
It's free for small projects up to 10,000 requests per month (IP and Referer identification). You can use ipwhois.io to filter out bot traffic, customize content based on visitor's location, display full country names, perform bulk IP geolocation, and more.
对于每月最多10,000个请求(IP和引用身份)的小型项目,它是免费的。 您可以使用ipwhois.io过滤出漫游器流量,根据访问者的位置自定义内容,显示完整的国家/地区名称,进行批量IP地理位置定位等等。