@@ -19,6 +19,7 @@ export type InvestmentMapFeature = {
|
||||
};
|
||||
};
|
||||
export type InvestmentMapArea = {
|
||||
purpose?: string;
|
||||
geometry: GeoJsonObject;
|
||||
title: string;
|
||||
source_reference?: string | null;
|
||||
@@ -30,9 +31,11 @@ const noAreas: InvestmentMapArea[] = [];
|
||||
export default function InteractiveInvestmentMap({
|
||||
points,
|
||||
areas = noAreas,
|
||||
contextOnly = false,
|
||||
}: {
|
||||
points: InvestmentMapFeature[] | null;
|
||||
areas?: InvestmentMapArea[];
|
||||
contextOnly?: boolean;
|
||||
}) {
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
const map = useRef<LeafletMap | null>(null);
|
||||
@@ -73,8 +76,19 @@ export default function InteractiveInvestmentMap({
|
||||
const bounds: [number, number][] = [];
|
||||
for (const area of areas) {
|
||||
const label = document.createElement('p');
|
||||
label.textContent = `${area.title} · Polígono cadastrado, limites oficiais por verificar · Fonte: ${area.source_reference ?? 'Não indicada'} · Data: ${area.source_date ?? 'Não documentada'}`;
|
||||
const layer = L.geoJSON(area.geometry)
|
||||
label.textContent = `${area.title} · ${area.purpose === 'administrative_boundary' ? 'Limite administrativo da edição indicada; não representa um local de investimento' : 'Polígono cadastrado, limites oficiais por verificar'} · Fonte: ${area.source_reference ?? 'Não indicada'} · Data: ${area.source_date ?? 'Não documentada'}`;
|
||||
const layer = L.geoJSON(
|
||||
area.geometry,
|
||||
area.purpose === 'administrative_boundary'
|
||||
? {
|
||||
style: {
|
||||
color: '#2563eb',
|
||||
dashArray: '5 5',
|
||||
fillOpacity: 0.06,
|
||||
},
|
||||
}
|
||||
: {},
|
||||
)
|
||||
.bindPopup(label)
|
||||
.addTo(instance);
|
||||
const extent = layer.getBounds();
|
||||
@@ -160,12 +174,22 @@ export default function InteractiveInvestmentMap({
|
||||
return (
|
||||
<section
|
||||
className="space-y-3 rounded-xl border bg-white p-4 text-slate-900"
|
||||
aria-label="Mapa interactivo dos investimentos"
|
||||
aria-label={
|
||||
contextOnly
|
||||
? 'Mapa dos limites administrativos'
|
||||
: 'Mapa interactivo dos investimentos'
|
||||
}
|
||||
>
|
||||
<h2 className="text-xl font-bold">Mapa dos investimentos</h2>
|
||||
<h2 className="text-xl font-bold">
|
||||
{contextOnly
|
||||
? 'Contexto administrativo'
|
||||
: 'Mapa dos investimentos'}
|
||||
</h2>
|
||||
<p>
|
||||
Arraste para navegar; use +/− para ampliar. Pode seleccionar um
|
||||
investimento na lista para o localizar.
|
||||
{contextOnly
|
||||
? 'limite cadastrado para consultar a sua edição.'
|
||||
: 'investimento na lista para o localizar.'}
|
||||
</p>
|
||||
{error && <p role="status">{error}</p>}
|
||||
<div
|
||||
@@ -177,7 +201,9 @@ export default function InteractiveInvestmentMap({
|
||||
<p role="status">A carregar localizações…</p>
|
||||
) : (
|
||||
<p role="status">
|
||||
{points.length} locais com coordenadas disponíveis.
|
||||
{contextOnly
|
||||
? `${areas.length} limites administrativos disponíveis.`
|
||||
: `${points.length} locais com coordenadas disponíveis.`}
|
||||
</p>
|
||||
)}
|
||||
<ul className="grid gap-2 md:grid-cols-2">
|
||||
|
||||
Reference in New Issue
Block a user