Giter Site home page Giter Site logo

make1122 / china-region Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shfshanyue/china-region

0.0 1.0 0.0 119 KB

根据国家标准《中华人民共和国行政区划代码》即 GB2260 标准制定,用以查看各个省地县的行政区划代码,并支持多级联动查询

JavaScript 21.45% TypeScript 78.55%

china-region's Introduction

**行政区划代码

npm version install size npm downloads

根据国家标准《中华人民共和国行政区划代码》即 GB2260 标准制定,用以查看各个省地县的行政区划代码,并支持多级联动查询

  1. 丰富的 API,满足多种级联查询
  2. 较小的 npm 包体积

版本

版本最近更新于 20210202,爬取数据为 http://preview.www.mca.gov.cn/article/sj/xzqh/2020/2020/202101041104.html

Install

$ npm install china-region

API

const cn = require('china-region')

const code = cn.getCodeByProvinceName('晋')

const cities = cn.getPrefectures(code)
// [
//   { code: '140100', name: '太原市' },
//   { code: '140200', name: '大同市' },
//   { code: '140300', name: '阳泉市' },
//   { code: '140400', name: '长治市' },
//   { code: '140500', name: '晋城市' },
//   { code: '140600', name: '朔州市' },
//   { code: '140700', name: '晋中市' },
//   { code: '140800', name: '运城市' },
//   { code: '140900', name: '忻州市' },
//   { code: '141000', name: '临汾市' },
//   { code: '141100', name: '吕梁市' }
// ]

cn.getCodeByProvinceName(name)

根据升级行政区名称或简称获取行政区划代码

// '140000'
cn.getCodeByProvinceName('山西省')

// '140000'
cn.getCodeByProvinceName('山西')

// '140000'
cn.getCodeByProvinceName('晋')

cn.info(code)

返回某个行政区号代表的行政区

// { name: '洪洞县', code: '141024', prefecture: '临汾市', province: '山西省' }
cn.info('141024')

// { name: '山西省', code: '140000', prefecture: null, province: null }
cn.info('140000')

cn.getAllRegions()

返回**所有的各级行政区

cn.getAllRegions()

cn.getProvinces()

返回**所有的省级行政区

cn.getProvinces()

cn.getPrefectures(code)

返回**/某省级行政区下所有的地级行政区

code 指行政区代码,code 为空时返回**所有的地级行政区,不为空时返回该省级行政区的所有地级行政区

// 列出**所有的地级行政区
cn.getPrefectures()

// 以下均列出 10 所代表省下辖的所有地级行政区
cn.getPrefectures('100000')
cn.getPrefectures('101000')
cn.getPrefectures('101010')

cn.getCounties(code)

返回**/某省级行政区/某地级行政区下所有的县级行政区

code 指行政区代码,code 为空时返回**所有的县级行政区,不为空时返回该省/市级行政区的所有地级行政区

// 列出**所有的县级行政区
cn.getCounties()

// 列出 10 所代表省下辖的所有县级行政区
cn.getCounties('100000')

// 列出 1010 所代表地下辖的所有县级行政区
cn.getCounties('101000')

cn.getSpecialConties(code)

返回**/某省级行政区下所有的省直管县。如海南省的各县和县级市、湖北省的仙桃市、潜江市、天门市、神农架林区、河南省的济源市、**的数个由自治区和**兵团双重领导的县级市等

code 指行政区代码,code 为空时返回**所有的县级行政区,不为空时返回该省/市级行政区的所有地级行政区

// 列出**所有的省直管县
cn.getSpecialCounties()

// 列出 10 所代表省下辖的所有省直管县
cn.getSpecialCounties('100000')

术语

关于行政区级别翻译参考知乎两篇关于地名翻译的文章

  • province,省级行政区,包括直辖市、省、自治区、特别行政区。
  • prefecture,地级行政区,包括地级市、地区、自治州、盟。
  • county,县级行政区,包括市辖区、县级市、县、自治县、旗、自治旗、特区、林区。
  • specialCounty,省直管县级行政区,如湖北的仙桃、潜江与天门

数据获取

行政代码在国家标准《中华人民共和国行政区划代码》即 GB2260 的标准下制定,可以在民政部统计数据中查询。

相关仓库

china-region's People

Contributors

shfshanyue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.