{"id":15366402,"url":"https://github.com/jasonboy/china-location","last_synced_at":"2025-04-05T07:05:21.853Z","repository":{"id":44153126,"uuid":"104843758","full_name":"JasonBoy/china-location","owner":"JasonBoy","description":"🇨🇳JS Library for Chinese Administrative Division. 中国行政区划信息-区划代码数据库(GB/T 2260)","archived":false,"fork":false,"pushed_at":"2022-12-08T19:09:09.000Z","size":2642,"stargazers_count":90,"open_issues_count":15,"forks_count":177,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T06:08:18.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JasonBoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-26T06:16:33.000Z","updated_at":"2024-08-26T12:59:06.000Z","dependencies_parsed_at":"2023-01-25T06:55:14.157Z","dependency_job_id":null,"html_url":"https://github.com/JasonBoy/china-location","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Fchina-location","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Fchina-location/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Fchina-location/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Fchina-location/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JasonBoy","download_url":"https://codeload.github.com/JasonBoy/china-location/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:18:42.261Z","updated_at":"2025-04-05T07:05:21.833Z","avatar_url":"https://github.com/JasonBoy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# china-location\n[![npm](https://img.shields.io/npm/v/china-location.svg)](https://www.npmjs.com/package/china-location)\n[![Building Status](https://travis-ci.org/JasonBoy/china-location.svg?branch=master)](https://travis-ci.org/JasonBoy/china-location)\n\nJS Library for [中国行政区划信息](https://github.com/mumuy/data_location#中国行政区划信息)  \nSimplify the usage of chinese administrative division data.\n\n[An React Component](https://github.com/JasonBoy/react-china-location) For this\n\n## Usage\n\n`npm install china-location --save` or\n`yarn add china-location`\n\n```javascript\nimport list from 'china-location/dist/location.json';\nimport ChinaLocation from 'china-location';\n//const ChinaLocation = require('china-location');\nconst location = new ChinaLocation(list);\n\n//get default location\n//{\n//  province: {code: '110000', name: '北京市'},\n//  city: {code: '110000', name: '北京市'},\n//  district: {code: '110101', name: '东城区'}\n//}\nconst defaultLocation = location.getCurrentAddress();\n\n//change location\nconst newProvince = '320000';\nconst newCity = '320500';\nconst newDistrict = '320509';\n//use select html tag to change different part\nlocation.changeProvince(newProvince);\nlocation.changeCity(newCity);\nlocation.changeDistrict(newDistrict);\n//or you can change location at one time\nlocation.changeLocation(newProvince, newCity, newDistrict);\n//{\n//  province: {code: '320000', name: '江苏省'},\n//  city: {code: '320500', name: '苏州市'},\n//  district: {code: '320509', name: '吴江区'}\n//}\nconst newLocation = location.getCurrentAddress();\n\n```\n\n## Build your own location.json\n\nIn case the package is not packed with the latest location data, get/clone the data from [mumuy/data_location(list.json)](https://github.com/mumuy/data_location),\nand clone this repo and:\n\n```bash\ngit clone git@github.com:JasonBoy/china-location.git\ncd china-location\nnpm run reformat -- /path/to/data_location/list.json\n# and the location(.min).json will be output to ./dist dir\n```\nAnd in your project, you can:\n\n```javascript\nimport yourNewLocation from 'path/to/location.json';\nimport ChinaLocation from 'china-location';\nconst location = new ChinaLocation(yourNewLocation);\n//...\n```\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonboy%2Fchina-location","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonboy%2Fchina-location","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonboy%2Fchina-location/lists"}