Skip to content

Commit 041591c

Browse files
Recommended Fixes
1 parent 1a657e7 commit 041591c

File tree

4 files changed

+23192
-8269
lines changed

4 files changed

+23192
-8269
lines changed

netmanager-app/components/NetManagerMap/page.tsx

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from 'react'
33
import { Input } from '../ui/input'
44
import mapboxgl from 'mapbox-gl';
55
import 'mapbox-gl/dist/mapbox-gl.css';
6+
import { ConvertToGeojson } from '@/lib/utils';
67

78
const NetManagerMap = () => {
89

@@ -157,10 +158,6 @@ const NetManagerMap = () => {
157158
}
158159
}
159160
});
160-
}{
161-
<div>
162-
Loading Data
163-
</div>
164161
}
165162
}, []);
166163

@@ -235,37 +232,7 @@ const NetManagerMap = () => {
235232
.catch(error => console.error("Error fetching location:", error));
236233

237234
}
238-
const ConvertToGeojson=(data: any)=>{
239-
return {
240-
type: "FeatureCollection" as const,
241-
features: data.measurements.map((item: any) => ({
242-
type: "Feature",
243-
geometry: {
244-
type: "Point",
245-
coordinates: [
246-
item.siteDetails.approximate_longitude,
247-
item.siteDetails.approximate_latitude
248-
]
249-
},
250-
properties: {
251-
id: item._id,
252-
site_id:item.site_id,
253-
time: new Date(item.time).toLocaleDateString("en-US", {
254-
weekday: "long",
255-
year: "numeric",
256-
month: "long",
257-
day: "numeric"
258-
}),
259-
location_name:item.siteDetails.name,
260-
aqi_category: item.aqi_category,
261-
aqi_color:item.aqi_color.startsWith("#") ? item.aqi_color : `#${item.aqi_color}`,
262-
value:item.pm2_5 ?.value??0,
263-
}
264-
}))
265-
}
266-
267-
268-
}
235+
269236

270237
return (
271238
<div className="flex flex-col-reverse md:flex md:flex-row min-h-screen md:h-screen -ml-5 ">

netmanager-app/lib/utils.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,35 @@ export const transformDataToGeoJson = (
4242
features,
4343
};
4444
};
45+
46+
export const ConvertToGeojson=(data: any)=>{
47+
return {
48+
type: "FeatureCollection" as const,
49+
features: data.measurements.map((item: any) => ({
50+
type: "Feature",
51+
geometry: {
52+
type: "Point",
53+
coordinates: [
54+
item.siteDetails.approximate_longitude,
55+
item.siteDetails.approximate_latitude
56+
]
57+
},
58+
properties: {
59+
id: item._id,
60+
site_id:item.site_id,
61+
time: new Date(item.time).toLocaleDateString("en-US", {
62+
weekday: "long",
63+
year: "numeric",
64+
month: "long",
65+
day: "numeric"
66+
}),
67+
location_name:item.siteDetails.name,
68+
aqi_category: item.aqi_category,
69+
aqi_color:item.aqi_color.startsWith("#") ? item.aqi_color : `#${item.aqi_color}`,
70+
value:item.pm2_5 ?.value??0,
71+
}
72+
}))
73+
}
74+
75+
76+
}

0 commit comments

Comments
 (0)