README
付迅行政区域 SDK
✅ http://preview.www.mca.gov.cn/article/sj/xzqh/2020/2020/202101041104.html 除港澳台(直辖市城区)外,所有省市县ID与此文档保持一致
安装
npm i @chuxingpay/location
// import multiple methods, json could be big, proceed with caution
const { getById, getCityById } = require("@chuxingpay/location")
// import single methods, will only load minimal necessary json, recommanded 👍
const { getById } = require("@chuxingpay/location/es/getById")
接口函数
Methods | @params | @return | Description | Recommand |
---|---|---|---|---|
getProvinceList | name='' | Array | 返回省列表 | 👍 |
getCityList | name='' | Array | 返回市列表 | 👍 |
getHotCities | Array | 返回热门城市列表(已排序) | 👍 | |
getByCityId | id='' | Array | 根据 citytId 查询 | 👍 |
getByProvinceId | id='' | Array | 根据 provinceId 查询 | 👍 |
getById | id='' | Object | 根据 id 查询省市区 | 👍 |
getCitiesByFirstLetter | letter='' | Array | 根据首字母查询城市列表 | 👍 |
getTree | depth=3 | Array | 根据 depth 查询(默认 3) (key 与其他方法有差异) | ✅ |
getByName | name='' | Array | 根据省/市/区/pinyin 查询 | ✅ |
getCityById | id='' | Object | 根据 id 查询城市 | ✅ |
getByDistrictId | id = '' | Array | 根据 districtId 查询 | ✅ |
getDistrictList | name='' | Array | 返回区列表 | ✅ |
getDistrictsByCityId | name='' | Array | 根据城市 ID 返回区列表 | ✅ |
getList | conds={} | Array | 组合条件查询 | 👎 |
✅ second param regionCode of each methods are default set to '100000' for future development
property changelog
[
{ // province obj
"pid": "100000",
"pname": "中国",
"id": "810000",
"name": "香港特别行政区",
"brief": "香港",
"lat": 22.320048,
"lng": 114.173355,
"level": 1,
"pinyin": "Xianggang",
"provinceId": "810000", 👎
"provinceName": "香港特别行政区", 👎
"latitude": 22.320048, 👎
"longtitude": 114.173355, 👎
"levelType": 1 👎
},
{ // city obj
"pid": "710000",
"pname": "台湾省",
"pnameEn": "Taiwan",
"id": "719013",
"name": "花莲县",
"brief": "花莲",
"lat": 23.973909,
"lng": 121.608198,
"level": 2,
"pinyin": "Hualian",
"provinceName": "台湾省", 👎
"provinceId": "710000", 👎
"cityName": "花莲县", 👎
"cityId": "719013", 👎
"latitude": 23.973909, 👎
"longtitude": 121.608198, 👎
"levelType": 2, 👎
"shortName": "花莲", 👎
"shortNameEn": "Hualian", 👎
},
{ // district obj
"pid": "120000",
"pname": "天津市",
"cid": "120100",
"cname": "天津城区",
"id": "120101",
"name": "和平区",
"lat": 39.118327,
"lng": 117.195907,
"level": 3,
"pinyin": "Hepingqu",
"provinceName": "天津市", 👎
"provinceId": "120000", 👎
"cityName": "天津城区", 👎
"cityId": "120100", 👎
"districtName": "和平区",
"districtId": "120101",
"latitude": 39.118327, 👎
"longtitude": 117.195907, 👎
"levelType": 3, 👎
}
]
✅ key with 👎 are deprecated and will be removed in next major release