svgmap-assam
v0.0.2
Published
Interactive map of Assam for React
Maintainers
Readme
Interactive Map of Assam
This package generates an interactive SVG map of Assam. It allows users to highlight districts on hover and retrieve the value of the selected district.

Installation
Install the package via npm:
pnpm install svgmap-assamDistrict List
The following are the districts mapped with its ID.
export const districtNames = {
TIN: 'Tinsukia',
DHE: 'Dhemaji',
DIB: 'Dibrugarh',
LAK: 'Lakhimpur',
SIV: 'Sivasagar',
JOR: 'Jorhat',
SON: 'Sonitpur',
GOL: 'Golaghat',
UDA: 'Udalguri',
CHI: 'Chirang',
BAK: 'Baksa',
NAG: 'Nagaon',
KOK: 'Kokrajhar',
DAR: 'Darrang',
BAR: 'Barpeta',
NAL: 'Nalbari',
MOR: 'Morigaon',
KAM: 'Kamrup',
BON: 'Bongaigaon',
DHU: 'Dhubri',
KMA: 'Kamrup Metropolitan',
GOA: 'Goalpara',
DHI: 'Dima Hasao',
CAC: 'Cachar',
KAR: 'Karimganj',
HAI: 'Hailakandi',
CHA: 'Charaideo',
MAJ: 'Majuli',
BIS: 'Biswanath',
HOJ: 'Hojai',
SSM: 'South Salmara Mankachar',
KAA: 'Karbi Anglong',
WKA: 'West Karbi Anglong',
}Usage
'use client'
import React, { useState } from 'react'
import AssamMap, { districtNames } from 'svgmap-assam'
const App = () => {
const [selectedValue, setSelectedValue] = useState<string | null>(null)
return (
<div>
<h3>{selectedValue ? `${selectedValue}: ${districtNames[selectedValue]}` : "None"}</h3>
<AssamMap
onClick={(value: string) => setSelectedValue(value)}
size="400px"
mapColor="white"
strokeColor="black"
strokeWidth="1"
hoverColor="rgb(80 80 80)"
/>
</div>
)
}
export default AppProps Available
| Props | Description | Requirement | Default Value | | ----------- | -------------------------------------------------- | ----------- | ------------- | | onClick | Callback function to get the selected state value. | Required | NA | | className | Custom classname for the map component. | Optional | "svgmap" | | size | Width of the map. | Optional | "inherit" | | mapColor | Color of the map. | Optional | "#ffffff" | | strokeColor | Border color of each state. | Optional | "#000000" | | strokeWidth | Border width of each state. | Optional | "0.5" | | hoverColor | Color of the state while hovering on it. | Optional | "#303030" |
Contributing
Pull requests are welcome.
