GithubHelp home page GithubHelp logo

harpreetkhalsagtbit / country-state-city Goto Github PK

View Code? Open in Web Editor NEW
254.0 254.0 159.0 33.34 MB

Basic library for Country, State and City

Home Page: country-state-city.vercel.app

License: GNU General Public License v3.0

JavaScript 0.70% TypeScript 99.30%

country-state-city's People

Contributors

ajstudd avatar brevis avatar cb-official avatar dependabot[bot] avatar dr5hn avatar eliasrodeloso avatar harpreetadpushup avatar harpreetkhalsagtbit avatar honia19 avatar mahdiboomeri avatar meunierfrederic avatar nishargshah avatar roksollc avatar taylorthurlow avatar utkarshgpta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

country-state-city's Issues

Insert these new data using their valid index

{
"id": "48357",
"name": "Abbotsford",
"state_id": "664"
},
{
"id": "48358",
"name": "Armstrong",
"state_id": "664"
},
{
"id": "48359",
"name": "Burnaby",
"state_id": "664"
},
{
"id": "48360",
"name": "Campbell River",
"state_id": "664"
},
{
"id": "48361",
"name": "Castlegar",
"state_id": "664"
},
{
"id": "48362",
"name": "Chilliwack",
"state_id": "664"
},
{
"id": "48363",
"name": "Colwood",
"state_id": "664"
},
{
"id": "48364",
"name": "Coquitlam",
"state_id": "664"
},
{
"id": "48365",
"name": "Courtenay",
"state_id": "664"
},
{
"id": "48366",
"name": "Cranbook",
"state_id": "664"
},
{
"id": "48367",
"name": "Dawson Creek",
"state_id": "664"
},
{
"id": "48368",
"name": "Delta",
"state_id": "664"
},
{
"id": "48369",
"name": "Duncan",
"state_id": "664"
},
{
"id": "48370",
"name": "Enderby",
"state_id": "664"
},
{
"id": "48371",
"name": "Fernie",
"state_id": "664"
},
{
"id": "48372",
"name": "Fort St. John",
"state_id": "664"
},
{
"id": "48373",
"name": "Grand Forks",
"state_id": "664"
},
{
"id": "48374",
"name": "Greenwood",
"state_id": "664"
},
{
"id": "48375",
"name": "Kamloops",
"state_id": "664"
},
{
"id": "48376",
"name": "Kelowna",
"state_id": "664"
},
{
"id": "48377",
"name": "Kimberley",
"state_id": "664"
},
{
"id": "48378",
"name": "Langford",
"state_id": "664"
},
{
"id": "48376",
"name": "Langley",
"state_id": "664"
},
{
"id": "48377",
"name": "Maple Ridge",
"state_id": "664"
},
{
"id": "48378",
"name": "Merritt",
"state_id": "664"
},
{
"id": "48379",
"name": "Nanaimo",
"state_id": "664"
},
{
"id": "48380",
"name": "Nelson",
"state_id": "664"
},
{
"id": "48381",
"name": "New Westminster",
"state_id": "664"
},
{
"id": "48382",
"name": "North Vancouver",
"state_id": "664"
},
{
"id": "48383",
"name": "Parksville",
"state_id": "664"
},
{
"id": "48384",
"name": "Penticton",
"state_id": "664"
},
{
"id": "48385",
"name": "Pitt Meadows",
"state_id": "664"
},
{
"id": "48386",
"name": "Port Alberni",
"state_id": "664"
},
{
"id": "48387",
"name": "Port Coquitlam",
"state_id": "664"
},
{
"id": "48388",
"name": "Port Moody",
"state_id": "664"
},
{
"id": "48389",
"name": "Powell River",
"state_id": "664"
},
{
"id": "48390",
"name": "Prince George",
"state_id": "664"
},
{
"id": "48391",
"name": "Prince Rupert",
"state_id": "664"
},
{
"id": "48392",
"name": "Quesnel",
"state_id": "664"
},
{
"id": "48393",
"name": "Revelstoke",
"state_id": "664"
},
{
"id": "48394",
"name": "Richmond",
"state_id": "664"
},
{
"id": "48395",
"name": "Rossland",
"state_id": "664"
},
{
"id": "48396",
"name": "Salmon Arm",
"state_id": "664"
},
{
"id": "48397",
"name": "Surrey",
"state_id": "664"
},
{
"id": "48398",
"name": "Terrace",
"state_id": "664"
},
{
"id": "48399",
"name": "Trail",
"state_id": "664"
},
{
"id": "48400",
"name": "Vancouver",
"state_id": "664"
},
{
"id": "48401",
"name": "Vernon",
"state_id": "664"
},
{
"id": "48402",
"name": "Victoria",
"state_id": "664"
},
{
"id": "48403",
"name": "West Kelowna",
"state_id": "664"
},
{
"id": "48404",
"name": "White Rock",
"state_id": "664"
},
{
"id": "48405",
"name": "Williams Lake",
"state_id": "664"
}]

Incorrect naming method for States and Cities of Arabian countries

Hello,
There is an issue across all cities and few states of Arabian countries, Where some cities are named using non-English characters. For example, in Egypt -> Cairo you will find a city called Ḩalwān which is written in a weird way even for Egyptians because it should be Helwan as mentioned in Wikipedia here https://en.wikipedia.org/wiki/Helwan
The issue is not only in Cairo city of Egypt but for almost all Arab countries.

This also makes the library not useful for systems that don't want users to write non-English addresses.
So please rewrite these countries and replace the letters with the correct alternative of English letters.

Morocoo | State Code

in version 2.0.0 of country-state-city package, for example i found city agadir info is :

{
        "name": "Agadir",
        "countryCode": "MA",
        "stateCode": "ASZ",
        "latitude": "30.42018000",
        "longitude": "-9.59815000"
},

the state code is 09 not ASZ, mean agadir in state Souss-Massa:
{
"name": "Souss-Massa",
"isoCode": "09",
"countryCode": "MA",
"latitude": "30.27506110",
"longitude": "-8.13385580"
}

hope to fixe this issues and anothers cities and share link when you import this list of data

Than you

Bundle size extremely large due to inclusion of cities database

Hi, I'm wondering if there are any plans to address the size of the included JSON database. Uncompressed, the countries, states, and cities databases are more than 16 megabytes, which is still more than 2.5 when fetched with a browser, gzip compressed.

This is sort of a deal-breaker for using this application in production for just countries and states, but would be 100% more usable if there were an option to exclude the cities database when one has no intention of using it. I don't know much about tree shaking and module exclusion, nor do I know how/if that would related to a big JSON document.

Maybe @dr5hn has an opinion or suggestions on this topic?

record of Auckland is repeated twice in states.json.

Auckland is present twice in states.json. as id: 245 and 2604 with different country_id

{ "id": "2604", "name": "Auckland", "country_id": "157" }

and

{ "id": "245", "name": "Auckland", "country_id": "13" }

cities in auckland are also split between them

Add black list

Black List

Some applications needs a black list of countries

How to implement

You can get all countries and filter by black list array passed in argument of getAllCountries

Can not find a city (Caracas capital of Venezuela) and the name of the state is wrong

Hi!

The name of the state is wrong. Indicates Distrito Federal (id: 4029) when it is Distrito Capital. It is a state of Venezuela (id: 237). https://en.wikipedia.org/wiki/Capital_District_(Venezuela). Observation: It is Distrito Capital in Spanish.

Caracas does not appear. Caracas belongs to the Distrito Capital (id: 4029) and is the capital of Venezuela (id: 237).

This I reported in the repository: https://github.com/hiiamrohit/Countries-States-Cities-database as issue: hiiamrohit/Countries-States-Cities-database#80

Thank you.

P.S. Excuse my English.

Mismetching state and country data for US

There is mismatch in data for US. Example, for Ohio State, there is ohio as a city. Also there are 60 states showing in list though the US have only 50 states. These are the cities which are showing as a states.

Byram
Cokato
District of Columbia
Lowa
Medfield
New Jersy
Ontario
Ramey
Sublimity
Trimble

image

Not all provinces and cities of pakistan was added correctly

Please add Khyber Pakhtunkhwa province and add at least following cities in it
Peshawar (01) | Mardan (02) | Mingora (03) | Kohat (04) Abbottabad (05)
Bannu (06) | Swabi (07) | Dera Ismail Khan(08) | Charsadda (09) | Nowshera (10)

Change the spelling of sind province to Sindh

Add Province "Azad and Jammu Kashmir" with at least following cities
Kotli (01) | Muzaffarabad (02) | Rawalakot (03) | New Mirpur City (04) | Bhimber (05)
Bagh (06) | Pallandri (07) | Athmuqam (08) | Hattian Bala (09) | Haveli (10)

Add Islamabad in Federal capital territory
I hope you do this
Thanks, in advance

Usage with react native

When I use this library with react native projects, I'm getting this Maximum call stack size exceeded error. So is this not usable for react native?

Usage with react for ios

When I use this library with reactive projects, I get the error Maximum call stack size exceeded. Only on phones with IOS

It fails to install after latest update

Node: 11.10.1

> 6 | import csc from 'country-state-city';
| ^
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node']. See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

Had to specify version for the CI to pass.
"country-state-city": "1.0.2"

Nigeria | Missing States

Some states in Nigeria are missing - the FCT (Abuja) and Rivers State.

[ 0: {name: "Abia State", isoCode: "AB", countryCode: "NG", latitude: "5.45273540", longitude: "7.52484140"} 1: {name: "Adamawa State", isoCode: "AD", countryCode: "NG", latitude: "9.32647510", longitude: "12.39838530"} 2: {name: "Akwa Ibom State", isoCode: "AK", countryCode: "NG", latitude: "4.90573710", longitude: "7.85366750"} 3: {name: "Anambra State", isoCode: "AN", countryCode: "NG", latitude: "6.22089970", longitude: "6.93695590"} 4: {name: "Bauchi State", isoCode: "BA", countryCode: "NG", latitude: "10.77606240", longitude: "9.99919430"} 5: {name: "Bayelsa State", isoCode: "BY", countryCode: "NG", latitude: "4.77190710", longitude: "6.06985260"} 6: {name: "Benue State", isoCode: "BE", countryCode: "NG", latitude: "7.33690240", longitude: "8.74036870"} 7: {name: "Borno State", isoCode: "BO", countryCode: "NG", latitude: "11.88463560", longitude: "13.15196650"} 8: {name: "Cross River State", isoCode: "CR", countryCode: "NG", latitude: "5.87017240", longitude: "8.59880140"} 9: {name: "Delta State", isoCode: "DE", countryCode: "NG", latitude: "33.74537840", longitude: "-90.73545080"} 10: {name: "Ebonyi State", isoCode: "EB", countryCode: "NG", latitude: "6.26492320", longitude: "8.01373020"} 11: {name: "Edo State", isoCode: "ED", countryCode: "NG", latitude: "6.63418310", longitude: "5.93040560"} 12: {name: "Ekiti State", isoCode: "EK", countryCode: "NG", latitude: "7.71898620", longitude: "5.31095050"} 13: {name: "Enugu State", isoCode: "EN", countryCode: "NG", latitude: "6.53635300", longitude: "7.43561940"} 14: {name: "Federal Capital Territory", isoCode: "FC", countryCode: "NG", latitude: "8.89406910", longitude: "7.18604020"} 15: {name: "Gombe State", isoCode: "GO", countryCode: "NG", latitude: "10.36377950", longitude: "11.19275870"} 16: {name: "Imo State", isoCode: "IM", countryCode: "NG", latitude: "5.57201220", longitude: "7.05882190"} 17: {name: "Jigawa State", isoCode: "JI", countryCode: "NG", latitude: "12.22801200", longitude: "9.56158670"} 18: {name: "Kaduna State", isoCode: "KD", countryCode: "NG", latitude: "10.37640060", longitude: "7.70945370"} 19: {name: "Kano State", isoCode: "KN", countryCode: "NG", latitude: "11.74706980", longitude: "8.52471070"} 20: {name: "Katsina State", isoCode: "KT", countryCode: "NG", latitude: "12.37967070", longitude: "7.63057480"} 21: {name: "Kebbi State", isoCode: "KE", countryCode: "NG", latitude: "11.49420030", longitude: "4.23333550"} 22: {name: "Kogi State", isoCode: "KO", countryCode: "NG", latitude: "7.73373250", longitude: "6.69058360"} 23: {name: "Kwara State", isoCode: "KW", countryCode: "NG", latitude: "8.96689610", longitude: "4.38740510"} 24: {name: "Lagos", isoCode: "LA", countryCode: "NG", latitude: "6.52437930", longitude: "3.37920570"} 25: {name: "Nasarawa State", isoCode: "NA", countryCode: "NG", latitude: "8.49979080", longitude: "8.19969370"} 26: {name: "Niger State", isoCode: "NI", countryCode: "NG", latitude: "9.93092240", longitude: "5.59832100"} 27: {name: "Ogun State", isoCode: "OG", countryCode: "NG", latitude: "6.99797470", longitude: "3.47373780"} 28: {name: "Ondo State", isoCode: "ON", countryCode: "NG", latitude: "6.91486820", longitude: "5.14781440"} 29: {name: "Osun State", isoCode: "OS", countryCode: "NG", latitude: "7.56289640", longitude: "4.51995930"} 30: {name: "Oyo State", isoCode: "OY", countryCode: "NG", latitude: "8.15738090", longitude: "3.61465340"} 31: {name: "Plateau State", isoCode: "PL", countryCode: "NG", latitude: "9.21820930", longitude: "9.51794880"} 32: {name: "Sokoto State", isoCode: "SO", countryCode: "NG", latitude: "13.05331430", longitude: "5.32227220"} 33: {name: "Taraba State", isoCode: "TA", countryCode: "NG", latitude: "7.99936160", longitude: "10.77398630"} 34: {name: "Yobe State", isoCode: "YO", countryCode: "NG", latitude: "12.29387600", longitude: "11.43904110"} 35: {name: "Zamfara State", isoCode: "ZA", countryCode: "NG", latitude: "12.12218050", longitude: "6.22358190"} ]

I hope you can fix this soon enough.

Thank you.

Get city details from country code and state name

There must be a way to have a function getCitiesOfStateByName ( countryCode, stateName ) where in we can fetch the city list by first fetching the stateCode from the database using the stateName and countryCode (maybe using getStatesOfCountry) and then using getCitiesOfState ( countryCode, stateCode)

bundle size too large

have issues with large bundle size (about 2mb gzip from just city/country/state data). when looking at bundle chunk, every city/country/state is being saved in the chunk even when i am only trying to import retrieve one country.

import {Country, State, City} from 'country-state-city';
const allCountries = Country.getCountryByCode('US')

getCountryById, getStateById, getCityById all returns incorrect information

getCountryById(), getStateById(), and getCityById() returns incorrect information. It will always return the record 1 ahead of the intended.

This is because these methods are access the country, state, and city arrays by index instead finding by id.

Reproduce:

import Csc from 'country-state-city'

var afghanistanCountry = Csc.getAllCountries()[0];

// afghanistanCountry === {
//   "id": "1",
//   "sortname": "AF",
//   "name": "Afghanistan",
//   "phonecode": "93"
// }

var albaniaCountry = Csc.getCountryById(1);

// albaniaCountry === {
//   "id": "2",
//   "sortname": "AL",
//   "name": "Albania",
//   "phonecode": "355"
// }

Multiple duplicates (cities with the same name, country and state)

Below is the list of parameters of all duplicate cities. Some occur multiple times, it means that there are more than 2 duplicate objects in the data. E.g., San Antonio in Philippines, Agusan del Sur province (["San Antonio", "PH", "AGS"]) is mentioned 5 times in the data, therefore, 4 corresponding duplicates are specified below.

[
["Arnoldstein", "AT", "2"],
["Bad Kleinkirchheim", "AT", "2"],
["Brückl", "AT", "2"],
["Dellach", "AT", "2"],
["Feistritz im Rosental", "AT", "2"],
["Ferndorf", "AT", "2"],
["Frauenstein", "AT", "2"],
["Friesach", "AT", "2"],
["Grafenstein", "AT", "2"],
["Gurk", "AT", "2"],
["Hüttenberg", "AT", "2"],
["Kirchbach", "AT", "2"],
["Lendorf", "AT", "2"],
["Maria Rain", "AT", "2"],
["Maria Wörth", "AT", "2"],
["Micheldorf", "AT", "2"],
["Millstatt", "AT", "2"],
["Moosburg", "AT", "2"],
["Mühldorf", "AT", "2"],
["Ruden", "AT", "2"],
["Schiefling am See", "AT", "2"],
["Seeboden", "AT", "2"],
["Stall", "AT", "2"],
["Steinfeld", "AT", "2"],
["Trebesing", "AT", "2"],
["Villach", "AT", "2"],
["Wernberg", "AT", "2"],
["Wolfsberg", "AT", "2"],
["Baia Mare", "RO", "MM"],
["Baia Sprie", "RO", "MM"],
["Borşa", "RO", "MM"],
["Cavnic", "RO", "MM"],
["Dragomireşti", "RO", "MM"],
["Seini", "RO", "MM"],
["Sighetu Marmaţiei", "RO", "MM"],
["Târgu Lăpuş", "RO", "MM"],
["Ulmeni", "RO", "MM"],
["Şomcuta Mare", "RO", "MM"],
["Săliştea de Sus", "RO", "MM"],
["Iclănzel", "RO", "MS"],
["La Mesa", "CO", "CUN"],
["Tibacuy", "CO", "CUN"],
["Útica", "CO", "CUN"],
["Agoo", "PH", "ABR"],
["Banna", "PH", "ABR"],
["Bued", "PH", "ABR"],
["Burgos", "PH", "ABR"],
["Burgos", "PH", "ABR"],
["Burgos", "PH", "ABR"],
["Gregorio del Pilar", "PH", "ABR"],
["Quirino", "PH", "ABR"],
["Salcedo", "PH", "ABR"],
["San Juan", "PH", "ABR"],
["San Juan", "PH", "ABR"],
["San Nicolas", "PH", "ABR"],
["Santa Maria", "PH", "ABR"],
["Santa Maria", "PH", "ABR"],
["Santo Tomas", "PH", "ABR"],
["Tagudin", "PH", "ABR"],
["Bagumbayan", "PH", "AGN"],
["Burgos", "PH", "AGN"],
["Dupax del Sur", "PH", "AGN"],
["Ilagan", "PH", "AGN"],
["Lal-lo", "PH", "AGN"],
["Malasin", "PH", "AGN"],
["Minanga Norte", "PH", "AGN"],
["Paddaya", "PH", "AGN"],
["Quezon", "PH", "AGN"],
["Rizal", "PH", "AGN"],
["San Antonio", "PH", "AGN"],
["San Isidro", "PH", "AGN"],
["San Jose", "PH", "AGN"],
["San Mateo", "PH", "AGN"],
["Santa Maria", "PH", "AGN"],
["Santo Niño", "PH", "AGN"],
["Tuao", "PH", "AGN"],
["Anao", "PH", "AGS"],
["Balite", "PH", "AGS"],
["Bamban", "PH", "AGS"],
["Burgos", "PH", "AGS"],
["Burgos", "PH", "AGS"],
["Concepcion", "PH", "AGS"],
["Concepcion", "PH", "AGS"],
["Del Pilar", "PH", "AGS"],
["Iba", "PH", "AGS"],
["Lambakin", "PH", "AGS"],
["Lourdes", "PH", "AGS"],
["Nampicuan", "PH", "AGS"],
["Pias", "PH", "AGS"],
["Plaridel", "PH", "AGS"],
["San Agustin", "PH", "AGS"],
["San Antonio", "PH", "AGS"],
["San Antonio", "PH", "AGS"],
["San Antonio", "PH", "AGS"],
["San Antonio", "PH", "AGS"],
["San Carlos", "PH", "AGS"],
["San Felipe", "PH", "AGS"],
["San Francisco", "PH", "AGS"],
["San Francisco", "PH", "AGS"],
["San Isidro", "PH", "AGS"],
["San Isidro", "PH", "AGS"],
["San Isidro", "PH", "AGS"],
["San Jose", "PH", "AGS"],
["San Juan", "PH", "AGS"],
["San Luis", "PH", "AGS"],
["San Manuel", "PH", "AGS"],
["San Miguel", "PH", "AGS"],
["San Nicolas", "PH", "AGS"],
["San Nicolas", "PH", "AGS"],
["San Rafael", "PH", "AGS"],
["San Rafael", "PH", "AGS"],
["San Roque", "PH", "AGS"],
["San Vicente", "PH", "AGS"],
["San Vicente", "PH", "AGS"],
["San Vicente", "PH", "AGS"],
["Santa Cruz", "PH", "AGS"],
["Santa Cruz", "PH", "AGS"],
["Santa Lucia", "PH", "AGS"],
["Santa Lucia", "PH", "AGS"],
["Santa Maria", "PH", "AGS"],
["Santa Maria", "PH", "AGS"],
["Santa Maria", "PH", "AGS"],
["Santa Rita", "PH", "AGS"],
["Santa Rosa", "PH", "AGS"],
["Santo Cristo", "PH", "AGS"],
["Santo Domingo", "PH", "AGS"],
["Santo Domingo", "PH", "AGS"],
["Santo Domingo", "PH", "AGS"],
["Santo Niño", "PH", "AGS"],
["Santo Rosario", "PH", "AGS"],
["Santo Tomas", "PH", "AGS"],
["Santo Tomas", "PH", "AGS"],
["Sasmuan", "PH", "AGS"],
["Sibul", "PH", "AGS"],
["Tanza", "PH", "00"],
["Banga", "PH", "BUK"],
["Bual", "PH", "BUK"],
["Buayan", "PH", "BUK"],
["Esperanza", "PH", "BUK"],
["Lambayong", "PH", "BUK"],
["Lebak", "PH", "BUK"],
["Liberty", "PH", "BUK"],
["M'lang", "PH", "BUK"],
["Pigcawayan", "PH", "BUK"],
["Alegria", "PH", "BUL"],
["Bayugan", "PH", "BUL"],
["Buenavista", "PH", "BUL"],
["Burgos", "PH", "BUL"],
["Carmen", "PH", "BUL"],
["Del Carmen", "PH", "BUL"],
["Gamut", "PH", "BUL"],
["La Paz", "PH", "BUL"],
["Libertad", "PH", "BUL"],
["Loreto", "PH", "BUL"],
["Nasipit", "PH", "BUL"],
["Rizal", "PH", "BUL"],
["Salvacion", "PH", "BUL"],
["Salvacion", "PH", "BUL"],
["San Agustin", "PH", "BUL"],
["San Francisco", "PH", "BUL"],
["San Francisco", "PH", "BUL"],
["San Francisco", "PH", "BUL"],
["San Isidro", "PH", "BUL"],
["Santa Maria", "PH", "BUL"],
["Santa Monica", "PH", "BUL"],
["Tandag", "PH", "BUL"],
["Jose Abad Santos", "PH", "BOH"],
["Kapalong", "PH", "BOH"],
["Mabini", "PH", "BOH"],
["Magsaysay", "PH", "BOH"],
["Magsaysay", "PH", "BOH"],
["Manay", "PH", "BOH"],
["Matanao", "PH", "BOH"],
["Mawab", "PH", "BOH"],
["Santo Niño", "PH", "BOH"],
["Ampatuan", "PH", "CAG"],
["Balindong", "PH", "CAG"],
["Bualan", "PH", "CAG"],
["Buan", "PH", "CAG"],
["Calanogas", "PH", "CAG"],
["Kapai", "PH", "CAG"],
["Pagalungan", "PH", "CAG"],
["Pagayawan", "PH", "CAG"],
["Parang", "PH", "CAG"],
["Sultan Kudarat", "PH", "CAG"],
["Sultan sa Barongis", "PH", "CAG"],
["Tapul", "PH", "CAG"],
["Tubaran", "PH", "CAG"],
["Calanasan", "PH", "CAN"],
["Hungduan", "PH", "CAN"],
["Tabuk", "PH", "CAN"],
["Jose Abad Santos", "PH", "DVO"],
["Kapalong", "PH", "DVO"],
["Mabini", "PH", "DVO"],
["Magsaysay", "PH", "DVO"],
["Magsaysay", "PH", "DVO"],
["Manay", "PH", "DVO"],
["Matanao", "PH", "DVO"],
["Mawab", "PH", "DVO"],
["Santo Niño", "PH", "DVO"],
];

How to get state name?

csc.getCitiesOfCountry(countryCode) gives array of cities with state code, I need to display state name. Is there a way I could get the state/province name?

P.S I did use getStateByCode() but in case of KP I should get Khybar Pakhtoon Khuwa but I get Kuyavian-Pomeranian Voivodeship

Flag is not showing on Chrome browser

Hi @harpreetkhalsagtbit,

I am facing an issue in displaying flags of country in cross browser platform. Country flag is visible on Mozilla Firefox but same is not working on Google Chrome.

Angular Version: 10.1.x

Please check attached image

This SS from Mozilla Firefox
image

This SS from Google Chrome
image

Please help.. Thanks in advance

Angular warnings because of commonjs

When building with Angular you get this warnings:

my-file.ts depends on 'country-state-city'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

I suggest that you have a ES version as well since at the moment the generated js will include Cities even though I only import Countries and States:

import { Country, State } from "country-state-city";

Use types interface for Country, State, City Object

from: @baywet

Just as a follow up, today I upgraded some of my production projects to this latest version.
Works well and is definitively an improvement over the previous version.

However I have an additional suggestion, today methods have an implicit return type or implicit any. If you declared interfaces for country and state, that'd allow consumers to leverage those interfaces in their code and provide even better type check.

    interface ICountry {
        id: string;
        name: string;
        phonecode: string;
        sortname: string;
    }
    interface IState {
        id: string;
        name: string;
        country_id: string;
    }
    interface ICity {
    id: string;
    name: string;
    state_id: string;
    }

And then all you should need to do is type the return of the methods like this

    getCountryById: function (id: string) : ICountry {
		return _findEntry(countryList, id);
	}

Need to request states by country code

giving only a getStatesOfCountry( _id: number ) function to fetch the list of states per country, where _id is a proprietary numeric ID of that country, is a bad idea.

Most databases have their own country id-s already built into them and there should be an option to getStatesOfCountryByCountryCode( _code: string ) option.

Where for example _code === "US", which is standardised and environment independent.

This is both an issue and a friendly suggestion from me, because this issue keeps me from using this library in larger projects, because there is already an established countryId system in place and those ID-s do not correlate with the ones in this repo.

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.