0.1.3 • Published 1 year ago

react-iran-provinces-map v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Iran Provinces Map

This NPM package provides interactive maps of Iran's provinces with city details and hover functionality. The package includes interactive and responsive SVG maps of all 31 provinces, each containing cities with customizable values displayed on hover. Additionally, the background color of each city changes based on it's count, creating a visually engaging experience for users.

You can use react-iran-map to create Iran map and get each province's name by clicking on it.

Installation

npm i react-iran-provinces-map

Usage

import { IranProvincesMap } from "react-iran-provinces-map";
import mapData from "../data.tsx";

function App() {
  const selectedProvince = "tehran";

  const selectProvinceHandler = (province) => {
    console.log(province);
  };

  return (
    <div style={{ fontFamily: "vazir" }}>
      <IranProvincesMap
        province={selectedProvince}
        provinceData={mapData}
        colorRange="30, 70, 181"
        deactiveProvinceColor="#eee"
        selectedProvinceColor="#3bcc6d"
        tooltipTitle="تعداد:"
        textColor="#000"
        width={600}
        selectProvinceHandler={selectProvinceHandler}
      />
    </div>
  );
}

export default App;

Data schema

You can see each province data in this link:

For example, you can use this data for 'tehran' as selected province:

const mapData = {
    malard: 10,
    shahriar: 23,
    robatkarim: 6,
    baharestan: 0,
    eslamshahr: 27,
    qods: 19,
    tehran: 29,
    rey: 1,
    varamin: 9,
    pishva: 2,
    qarchak: 17,
    pakdasht: 14,
    damavand: 25,
    pardis: 21,
    shemiranat: 11,
    firuzkuh: 3,
};

Available attributes

NameTypeRequiredDescription
provincestringTrueSelected province name
provinceDataObjectTrueAn object that has 'Data schema' items as cities for each province
colorRangestringTrueIt defines the range of color based on it's value and it should be rgb color like this : "30, 70, 181"
widthnumberFalseWidth of the map
textColorstringFalseColor of map texts
deactiveProvinceColorstringFalseIt set color of the provinces with 0 value
selectedProvinceColorstringFalseColor of the clicked city
tooltipTitlestringFalseYou can add a name for the value in tooltip
selectProvinceHandlerfunctionFalseYou can define a function like example above to get selected city name

Authors