This simple library helps you find Philippine regions, cities, and municipalities. Perfect for dropdown menus, forms, and search filters in your applications.
To start using the ph-regions-cities-municipalities library, follow these steps:
- Visit the Releases page to download.
- Choose the latest version.
- Download the package that suits your needs.
You can easily add this library to your project.
Open your terminal and run:
npm install ph-regions-cities-municipalitiesIf you're using Yarn, run:
yarn add ph-regions-cities-municipalitiesOnce you've installed the library, you can start using it in your project.
Add the following line at the top of your TypeScript file:
import locations from "ph-regions-cities-municipalities";You can retrieve all regions easily. Use the following code:
console.log(locations.states);
/*
Output example:
[
{
iso2: 'PH104200000',
name: 'Misamis Occidental',
id: 0
}
]
*/If you need to get cities from a specific province, use the province code:
const provinceCode = "PH104200000"; // Example for Misamis Occidental
console.log(locations.statesMap[provinceCode]);
/*
Output example:
[
{
id: 0,
name: 'Ozamis City'
}
]
*/This library provides a structured map of Philippine regions, cities, and municipalities. Each state contains an identifier, name, and an array of cities. You can use this data in various applications, such as forms or search filters, to improve user experience.
Imagine you want to create a registration form that asks users for their addresses. You can use this library to populate a dropdown with regions and corresponding cities.
- When the user selects a region, you can fetch the cities associated with that region.
- The user then chooses their city from the updated list.
This provides a simple and clear way to input location data.
- Comprehensive Dataset: Contains all Philippine regions and their respective cities and municipalities.
- Easy Integration: Simple to add to your existing TypeScript projects.
- Dynamic Updates: Automatically updates to include new regions or cities, ensuring your application uses the most current data.
If you encounter issues:
- Ensure you have a stable internet connection while downloading.
- Verify that you have the necessary permissions to install packages if you are using a work computer.
- Make sure you are using compatible versions of npm or Yarn.
For any questions or support, feel free to open an issue in the GitHub repository.