-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
196 lines (177 loc) Β· 4.43 KB
/
Copy pathdata.js
File metadata and controls
196 lines (177 loc) Β· 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// async function initMap() {
// // π Initialize map
// map = new google.maps.Map(document.getElementById("map"), {
// center: { lat: 22.9734, lng: 78.6569 }, // India center
// zoom: 5
// // const bounds = new google.maps.LatLngBounds();
// // highRisk.forEach(zone => {
// // bounds.extend({
// // lat: zone.center[0],
// // lng: zone.center[1]
// // });
// // });
// // map.fitBounds(bounds);
// });
// try {
// // π‘ Fetch backend data
// const highRisk = data.high_risk_zones;
// const predicted = data.predicted_zones;
// // π΄ STEP 1 β Draw Circles (High Risk Zones)
// highRisk.forEach(zone => {
// new google.maps.Circle({
// strokeColor: zone.risk_level === "High" ? "#FF0000" : "#FFA500",
// strokeOpacity: 0.8,
// strokeWeight: 2,
// fillColor: zone.risk_level === "High" ? "#FF0000" : "#FFA500",
// fillOpacity: 0.35,
// map: map,
// center: {
// lat: zone.center[0],
// lng: zone.center[1]
// },
// radius: zone.radius_km * 1000
// });
// });
// // π₯ STEP 2 β Heatmap Layer
// const heatData = highRisk.map(zone => ({
// location: new google.maps.LatLng(
// zone.center[0],
// zone.center[1]
// ),
// weight: zone.avg_score || 1
// }));
// const heatmap = new google.maps.visualization.HeatmapLayer({
// data: heatData,
// radius: 30
// });
// heatmap.setMap(map);
// // π STEP 3 β Predicted Zones Markers
// predicted.forEach(p => {
// if (p.lat && p.lng) {
// const marker = new google.maps.Marker({
// position: { lat: p.lat, lng: p.lng },
// map: map,
// title: p.issue_type
// });
// // π§ Optional: Info Window on click
// const infoWindow = new google.maps.InfoWindow({
// content: `
// <div>
// <strong>Issue:</strong> ${p.issue_type}<br/>
// <strong>Location:</strong> ${p.location}
// </div>
// `
// });
// marker.addListener("click", () => {
// infoWindow.open(map, marker);
// });
// }
// });
// } catch (error) {
// console.error("Error fetching data:", error);
// }
// }
// // π Load map
// window.onload = initMap;
const data = {
high_risk_zones: [
{
center: [28.61, 77.20], // Delhi
radius_km: 25,
risk_level: "High",
avg_score: 0.9
},
{
center: [19.07, 72.87], // Mumbai
radius_km: 20,
risk_level: "High",
avg_score: 0.85
},
{
center: [13.08, 80.27], // Chennai
radius_km: 18,
risk_level: "Medium",
avg_score: 0.6
},
{
center: [22.57, 88.36], // Kolkata
radius_km: 22,
risk_level: "High",
avg_score: 0.8
},
{
center: [12.97, 77.59], // Bangalore
radius_km: 15,
risk_level: "Medium",
avg_score: 0.55
},
{
center: [23.03, 72.58], // Ahmedabad
radius_km: 17,
risk_level: "Medium",
avg_score: 0.5
},
{
center: [26.91, 75.79], // Jaipur
radius_km: 16,
risk_level: "Low",
avg_score: 0.3
},
{
center: [17.38, 78.48], // Hyderabad
radius_km: 19,
risk_level: "Medium",
avg_score: 0.65
}
],
predicted_zones: [
{
location: "Delhi",
lat: 28.61,
lng: 77.20,
issue_type: "Air Pollution"
},
{
location: "Mumbai",
lat: 19.07,
lng: 72.87,
issue_type: "Flood Risk"
},
{
location: "Chennai",
lat: 13.08,
lng: 80.27,
issue_type: "Water Scarcity"
},
{
location: "Kolkata",
lat: 22.57,
lng: 88.36,
issue_type: "Air Pollution"
},
{
location: "Bangalore",
lat: 12.97,
lng: 77.59,
issue_type: "Traffic Congestion"
},
{
location: "Hyderabad",
lat: 17.38,
lng: 78.48,
issue_type: "Heat Waves"
},
{
location: "Jaipur",
lat: 26.91,
lng: 75.79,
issue_type: "Water Scarcity"
},
{
location: "Ahmedabad",
lat: 23.03,
lng: 72.58,
issue_type: "Heat Waves"
}
]
};