This document describes the universal CustomAreaDashboard and CustomAreaMap components that can be used to create area-specific dashboards for any country or region.
A universal dashboard component that provides a complete interface for viewing area-specific reports and statistics.
A universal map component that displays area boundaries, reports, and statistics with configurable administrative levels.
import CustomAreaDashboard from '../components/CustomAreaDashboard';
export default function MyAreaPage() {
return (
<CustomAreaDashboard
apiUrl="https://your-api-url.com"
mapCenter={[latitude, longitude]}
adminLevel={2}
subAdminLevel={6}
countryOsmId={-12345}
areaName="My Country"
areaFlag="🏳️"
/>
);
}| Parameter | Type | Required | Description |
|---|---|---|---|
apiUrl |
string |
Yes | The base URL for the area's API endpoint |
mapCenter |
[number, number] |
Yes | The center coordinates for the map (latitude, longitude) |
areaName |
string |
Yes | The display name for the area |
areaFlag |
string |
No | Optional flag emoji to display in the header |
| Parameter | Type | Required | Description |
|---|---|---|---|
mapCenter |
[number, number] |
Yes | The center coordinates for the map |
apiUrl |
string |
Yes | The base URL for the area's API endpoint |
areaName |
string |
No | Optional area name for internal use |
The components use OpenStreetMap administrative levels:
- Admin Level 2: Country boundaries
- Admin Level 6: Municipality/county boundaries
These levels can be adjusted based on your specific area's administrative structure.
The components expect the following API endpoints:
- Reports:
${apiUrl}/reports?n=${MAX_REPORTS_LIMIT} - Aggregated Data:
${apiUrl}/reports_aggr - Areas:
${apiUrl}/areas - Sub Areas:
${apiUrl}/sub_areas
{
"reports": [
{
"report": {
"seq": 12345,
"timestamp": "2024-01-01T12:00:00Z",
"id": "report-id",
"latitude": 42.7087,
"longitude": 19.3744,
"image": "image-url"
},
"analysis": {
"seq": 12345,
"title": "Report Title",
"description": "Report Description",
"litter_probability": 0.8,
"hazard_probability": 0.2,
"severity_level": 0.7,
"summary": "Report Summary"
}
}
]
}{
"areas": [
{
"osm_id": 12345,
"name": "Area Name",
"reports_count": 100,
"reports_max": 200,
"reports_mean": 150,
"mean_severity": 0.6,
"mean_litter_probability": 0.7,
"mean_hazard_probability": 0.3
}
]
}{
"polygons": [
{
"osm_id": 12345,
"name": "Area Name",
"area": {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [[[lat1, lng1], [lat2, lng2], ...]]
}
}
}
]
}<CustomAreaDashboard
apiUrl={process.env.NEXT_PUBLIC_MONTENEGRO_API_URL || ''}
mapCenter={[42.7087, 19.3744]}
areaName="Montenegro"
areaFlag="🇲🇪"
/><CustomAreaDashboard
apiUrl="https://api.mycountry.com"
mapCenter={[40.7128, -74.0060]}
areaName="My Country"
areaFlag="🏳️"
/>- Interactive Map: View area boundaries and reports
- Statistics Mode: Color-coded areas based on report statistics
- Reports Mode: View individual report markers
- Report Management: Mark reports as fixed and remove them from the map
- Authentication: Secure access with bearer token authentication
- Multi-language Support: Built-in internationalization support
- Responsive Design: Works on desktop and mobile devices
The new components are backward compatible. To migrate from the old Montenegro components:
- Replace
MontenegroDashboardwithCustomAreaDashboard - Replace
MontenegroMapwithCustomAreaMap - Add the required props as shown in the examples above
- Update any import statements
The old Montenegro components can be safely removed after migration.