最近项目开发遇到需要经纬度判断用户所在国家城市
考虑到有国外用户,不考虑百度地图api,谷歌地图api太贵,所以才找了开源的
通过ip获取的国家城市有可能存在用户VPN的情况
经纬度也有可能用户做虚拟定位,看情况使用
这个接口是荷兰的地图api
https://nominatim.openstreetmap.org/reverse?format=json&lat=43.816713&lon=-109.651912&zom=18&addressdetails=1
返回数据
{
"place_id": 197915594,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"osm_type": "relation",
"osm_id": 288533,
"lat": "43.0293336",
"lon": "-108.5772551",
"display_name": "Fremont County, 懷俄明州, 美国",
"address": {
"county": "Fremont County",
"state": "懷俄明州",
"country": "美国",
"country_code": "us"
},
"boundingbox": ["42.259571", "44.009157", "-110.053637", "-107.494125"]
}
网友评论