harpreetkhalsagtbit / country-state-city Goto Github PK
View Code? Open in Web Editor NEWBasic library for Country, State and City
Home Page: country-state-city.vercel.app
License: GNU General Public License v3.0
Basic library for Country, State and City
Home Page: country-state-city.vercel.app
License: GNU General Public License v3.0
I need to retrieve county data as well
When I use this library with reactive projects, I get the error Maximum call stack size exceeded. Only on phones with IOS
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.
Hi @harpreetkhalsagtbit Buddy,
I faced a few issues:
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
Does this work with react native?
Need to change the data structure of Countries, state, cities from array form to object form or any other better data structure because adding or removing any element from any JSON file breaks elements index, hash or Object seems to be more scalable.
Also, we need to figure out a way to load JSON in chunks for mobile devices
related issue - #18
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?
Continents add valuable context to a country object. Moreover, they are useful in grouping countries together.
Not all Australian City and Suburbs are included, for example simply Sydney or Suburb in Sydney Mosman, Suburb in Melbourne, Beaumaris etc
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
Please help.. Thanks in advance
Hi
I have this code sample and it doesn’t open in Iphone real device.
dose anyone know why?
https://codesandbox.io/s/fervent-sunset-77f2sv?file=/src/App.tsx
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"],
];
We will be adding more cities for Philippines.
Can please share what will be ETA turnaroud to accept PR?
This will be really helpful in cases where we are using the entire city object as the value in a dropdown.
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')
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)
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);
}
Extra incorrect states in USA, south africa 60 states, few of them are incorrect e.g state 'Cokato' in USA
tried to install @latest (1.0.3) which is not bringing in all the repo files in the install.
on the other hand 1.0.2 seems to be a stable one.
Many PRs and bugs have been opened and not addressed ?
Are you still working on it ?
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.
Is there a reason why we return empty string and not undefined,
country-state-city/lib/country.ts
Line 7 in a6ed495
A number of municipalities, such as Irkutsk, Yerbogachen, Zalari, Yelantsy, Ust’-Kut, Tulun etc. (100 to 145 in total, by my estimation) were assigned the stateCode "UA-40" instead of "IRK"
It only have state code and country code but city hasn't 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
Some applications needs a black list of countries
You can get all countries and filter by black list array passed in argument of getAllCountries
@harpreetkhalsagtbit We need to add Migration Guidelines from Moving v1.x to v2.x
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
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";
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"
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
{
"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"
}]
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.
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?
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.
sorry
Hey!
Thanks for putting together this project.
Would you consider switching to typescript or at least adding type definitions?
This way we'd have compile time validation.
There are two regions for Italy, Abruzzo
and Abruzzi
, which should be only Abruzzo
.
You can find the full list (20) here: https://it.wikipedia.org/wiki/Regioni_d%27Italia#Dati_demografici_e_geografici
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"
// }
I think the 3rd party copy-webpack-plugin needs to be moved to the dev dependencies as it's normally used for the build system.
country-state-city/package.json
Lines 62 to 64 in 140d6a1
@harpreetkhalsagtbit Just a suggestion,
Can we use this DB?
https://github.com/dr5hn/countries-states-cities-database
P.S. If you want I can help you with whatever JSON format you require to make your efforts a little less. 🥂
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
Missing: countryCode
Don't we need the countryCode here?
I had to disabled the commonjs plugin for rollup as it causes this package to error when importing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.