GithubHelp home page GithubHelp logo

shopexdream / china-location Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jasonboy/china-location

0.0 2.0 0.0 905 KB

🇨🇳NPM Module for Chinese Administrative Division. **行政区划信息-区划代码数据库(GB/T 2260)

License: MIT License

JavaScript 100.00%

china-location's Introduction

china-location

npm Building Status

NPM module for **行政区划信息
Simplify the use of chinese administrative division data.

An React Component For this

Usage

npm install china-location --save or yarn add china-location

const list = require('china-location/dist/location.json');
const ChinaLocation = require('china-location');
const location = new ChinaLocation(list);

//get default location
//{
//  province: {code: '110000', name: '北京市'},
//  city: {code: '110000', name: '北京市'},
//  district: {code: '110101', name: '东城区'}
//}
const defaultLocation = location.getCurrentAddress();

//change location
const newProvince = '320000';
const newCity = '320500';
const newDistrict = '320509';
//use select html tag to change different part
location.changeProvince(newProvince);
location.changeCity(newCity);
location.changeDistrict(newDistrict);
//or you can change location at one time
location.changeLocation(newProvince, newCity, newDistrict);
//{
//  province: {code: '320000', name: '江苏省'},
//  city: {code: '320500', name: '苏州市'},
//  district: {code: '320509', name: '吴江区'}
//}
const newLocation = location.getCurrentAddress();

Build your own location.json

In case the package is not packed with the latest location data, get/clone the data from mumuy/data_location(list.json), and clone this repo and:

git clone [email protected]:JasonBoy/china-location.git
cd china-location
npm run reformat -- /path/to/data_location/list.json
# and the location(.min).json will be output to ./dist dir

And in your project, you can:

const yourNewLocation = require('path/to/location.json');
const ChinaLocation = require('china-location');
const location = new ChinaLocation(yourNewLocation);
//...

LICENSE

MIT

china-location's People

Contributors

mumuy avatar jasonboy avatar kidxo avatar

Watchers

James Cloos avatar Showker 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.