india-map-react 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +38 -0
- package/README.md +252 -0
- package/dist/index.cjs +403 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +125 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +375 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kunwar Yuvraj Durgesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
BOUNDARY DATA NOTICE
|
|
26
|
+
|
|
27
|
+
The TopoJSON boundary data included in this package is derived from publicly
|
|
28
|
+
available government sources and is provided solely for visualization and
|
|
29
|
+
general informational purposes. It is NOT intended for legal, surveying,
|
|
30
|
+
navigational, or any official use.
|
|
31
|
+
|
|
32
|
+
Minor geometric variations may exist due to data simplification and rendering
|
|
33
|
+
optimizations. For authoritative and legally binding boundary information,
|
|
34
|
+
refer to official sources such as the Survey of India
|
|
35
|
+
(https://www.surveyofindia.gov.in/).
|
|
36
|
+
|
|
37
|
+
This project is not an official government product and is not affiliated with
|
|
38
|
+
or endorsed by the Government of India or any of its agencies.
|
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# india-map-react
|
|
2
|
+
|
|
3
|
+
Interactive React component for India's map with state-level interactions.
|
|
4
|
+
Uses the **official India boundary TopoJSON** (ST_NM property).
|
|
5
|
+
|
|
6
|
+
> ⚠️ **Disclaimer**
|
|
7
|
+
> This map is provided for **visualization and general informational purposes only**.
|
|
8
|
+
> It follows the official boundaries of India as per publicly available government data sources.
|
|
9
|
+
> The boundaries shown are **not intended for legal, surveying, or navigational use**. Minor variations in geometry may exist due to data simplification and rendering optimizations.
|
|
10
|
+
> For authoritative and legally binding boundaries, please refer to official sources such as the [Survey of India](https://www.surveyofindia.gov.in/).
|
|
11
|
+
>
|
|
12
|
+
> This project is **not an official government product**.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install india-map-react react-simple-maps
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { IndiaMap } from "india-map-react";
|
|
24
|
+
|
|
25
|
+
export default function App() {
|
|
26
|
+
return (
|
|
27
|
+
<IndiaMap
|
|
28
|
+
onStateClick={(name) => console.log(name)}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
| Feature | Prop |
|
|
37
|
+
|---|---|
|
|
38
|
+
| State click | `onStateClick` |
|
|
39
|
+
| Hover callback | `onStateHover`, `onStateLeave` |
|
|
40
|
+
| Tooltip (built-in) | `showTooltip`, `tooltipContent` |
|
|
41
|
+
| Zoom + pan | `enableZoom`, `minZoom`, `maxZoom` |
|
|
42
|
+
| Choropleth coloring | `enableChoropleth`, `stateData` |
|
|
43
|
+
| Per-state custom color | `stateData[name].color` |
|
|
44
|
+
| Map markers / pins | `markers`, `onMarkerClick` |
|
|
45
|
+
| Multi-select | `multiSelect` |
|
|
46
|
+
| Controlled selection | `selectedState` |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Props Reference
|
|
51
|
+
|
|
52
|
+
### Data
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `stateData` | `Record<string, StateData>` | Per-state values / colors. Key = state name (ST_NM). |
|
|
57
|
+
| `markers` | `MarkerData[]` | Array of pins to render on the map. |
|
|
58
|
+
|
|
59
|
+
### Colors
|
|
60
|
+
|
|
61
|
+
| Prop | Default | Description |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `fillColor` | `"#1A1A2E"` | Default state fill |
|
|
64
|
+
| `hoverColor` | `"#2D2D5A"` | Fill on hover |
|
|
65
|
+
| `selectedColor` | `"#4f46e5"` | Fill for selected state |
|
|
66
|
+
| `strokeColor` | `"#444"` | Border between states |
|
|
67
|
+
| `strokeWidth` | `0.5` | Border width |
|
|
68
|
+
|
|
69
|
+
### Choropleth
|
|
70
|
+
|
|
71
|
+
| Prop | Default | Description |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `enableChoropleth` | `false` | Enable value-based coloring |
|
|
74
|
+
| `choroplethLow` | `"#dbeafe"` | Color for lowest value |
|
|
75
|
+
| `choroplethHigh` | `"#1d4ed8"` | Color for highest value |
|
|
76
|
+
|
|
77
|
+
### Behavior
|
|
78
|
+
|
|
79
|
+
| Prop | Default | Description |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `selectedState` | — | Controlled selected state name |
|
|
82
|
+
| `multiSelect` | `false` | Allow multiple selections |
|
|
83
|
+
| `disabled` | `false` | Disable all interactions |
|
|
84
|
+
|
|
85
|
+
### Zoom
|
|
86
|
+
|
|
87
|
+
| Prop | Default | Description |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `enableZoom` | `false` | Scroll-wheel zoom + drag-to-pan |
|
|
90
|
+
| `minZoom` | `1` | Minimum zoom level |
|
|
91
|
+
| `maxZoom` | `8` | Maximum zoom level |
|
|
92
|
+
|
|
93
|
+
### Tooltip
|
|
94
|
+
|
|
95
|
+
| Prop | Default | Description |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| `showTooltip` | `true` | Show tooltip on hover |
|
|
98
|
+
| `tooltipContent` | — | `(name, data?) => ReactNode` — custom tooltip |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
### Basic click + tooltip
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<IndiaMap
|
|
108
|
+
showTooltip
|
|
109
|
+
onStateClick={(name) => alert(`Clicked: ${name}`)}
|
|
110
|
+
/>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Choropleth — population density
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { IndiaMap, Legend } from "india-map-react";
|
|
117
|
+
|
|
118
|
+
const populationData = {
|
|
119
|
+
"Uttar Pradesh": { value: 241 },
|
|
120
|
+
"Maharashtra": { value: 123 },
|
|
121
|
+
"Bihar": { value: 128 },
|
|
122
|
+
"West Bengal": { value: 107 },
|
|
123
|
+
// ...
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
<IndiaMap
|
|
127
|
+
stateData={populationData}
|
|
128
|
+
enableChoropleth
|
|
129
|
+
choroplethLow="#eff6ff"
|
|
130
|
+
choroplethHigh="#1d4ed8"
|
|
131
|
+
tooltipContent={(name, data) => (
|
|
132
|
+
<span>{name}: <strong>{data?.value ?? "N/A"}</strong> million</span>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
<Legend
|
|
137
|
+
title="Population (millions)"
|
|
138
|
+
minLabel="Low"
|
|
139
|
+
maxLabel="High"
|
|
140
|
+
lowColor="#eff6ff"
|
|
141
|
+
highColor="#1d4ed8"
|
|
142
|
+
style={{ marginTop: 8 }}
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Per-state custom colors
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<IndiaMap
|
|
150
|
+
stateData={{
|
|
151
|
+
"Kerala": { color: "#4ade80" },
|
|
152
|
+
"Rajasthan": { color: "#fb923c" },
|
|
153
|
+
"West Bengal": { color: "#f472b6" },
|
|
154
|
+
}}
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Markers (city pins)
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
<IndiaMap
|
|
162
|
+
markers={[
|
|
163
|
+
{ id: "del", label: "Delhi", lat: 28.61, lng: 77.20, color: "#f59e0b" },
|
|
164
|
+
{ id: "mum", label: "Mumbai", lat: 19.08, lng: 72.88, color: "#ec4899" },
|
|
165
|
+
{ id: "ben", label: "Bengaluru", lat: 12.97, lng: 77.59, color: "#22d3ee" },
|
|
166
|
+
]}
|
|
167
|
+
onMarkerClick={(marker) => console.log("Marker clicked:", marker.label)}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Zoom + pan
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
<IndiaMap
|
|
175
|
+
enableZoom
|
|
176
|
+
minZoom={1}
|
|
177
|
+
maxZoom={10}
|
|
178
|
+
/>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Multi-select
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
const [selected, setSelected] = useState<string[]>([]);
|
|
185
|
+
|
|
186
|
+
<IndiaMap
|
|
187
|
+
multiSelect
|
|
188
|
+
onStateClick={(name) =>
|
|
189
|
+
setSelected((prev) =>
|
|
190
|
+
prev.includes(name) ? prev.filter(n => n !== name) : [...prev, name]
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
/>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Custom tooltip
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
<IndiaMap
|
|
200
|
+
showTooltip
|
|
201
|
+
tooltipContent={(name, data) => (
|
|
202
|
+
<div>
|
|
203
|
+
<strong>{name}</strong>
|
|
204
|
+
{data?.value && <p>GDP: ₹{data.value}L Cr</p>}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
/>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## State Names Reference
|
|
213
|
+
|
|
214
|
+
The TopoJSON uses `ST_NM` for state names. All 36 states and UTs:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
Andaman & Nicobar, Andhra Pradesh, Arunachal Pradesh, Assam, Bihar,
|
|
218
|
+
Chandigarh, Chhattisgarh, Dadra and Nagar Haveli and Daman and Diu,
|
|
219
|
+
Delhi, Goa, Gujarat, Haryana, Himachal Pradesh, Jammu & Kashmir,
|
|
220
|
+
Jharkhand, Karnataka, Kerala, Ladakh, Lakshadweep, Madhya Pradesh,
|
|
221
|
+
Maharashtra, Manipur, Meghalaya, Mizoram, Nagaland, Odisha,
|
|
222
|
+
Puducherry, Punjab, Rajasthan, Sikkim, Tamil Nadu, Telangana,
|
|
223
|
+
Tripura, Uttar Pradesh, Uttarakhand, West Bengal
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Exports
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { IndiaMap } from "india-map-react"; // main map
|
|
232
|
+
import { Legend } from "india-map-react"; // choropleth legend
|
|
233
|
+
import type { IndiaMapProps, StateData, MarkerData } from "india-map-react";
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## ⚠️ Disclaimer
|
|
239
|
+
|
|
240
|
+
This map is provided for **visualization and general informational purposes only**.
|
|
241
|
+
|
|
242
|
+
It follows the official boundaries of India as per publicly available government data sources. The boundaries shown are **not intended for legal, surveying, or navigational use**. Minor variations in geometry may exist due to data simplification and rendering optimizations.
|
|
243
|
+
|
|
244
|
+
For authoritative and legally binding boundaries, please refer to official sources such as the [Survey of India](https://www.surveyofindia.gov.in/).
|
|
245
|
+
|
|
246
|
+
**This project is not an official government product.**
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT © [KUNWAR YUVRAJ DURGESH](./LICENSE)
|