fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -76,12 +76,25 @@ export default function InteractiveInvestmentMap({
|
||||
.addTo(instance);
|
||||
L.control.scale({ imperial: false }).addTo(instance);
|
||||
const bounds: [number, number][] = [];
|
||||
const hasSelectedBoundary = areas.some((area) => area.selected_territory);
|
||||
const hasSelectedBoundary = areas.some(
|
||||
(area) => area.selected_territory,
|
||||
);
|
||||
const administrativeLevel: Record<string, number> = {
|
||||
province: 1, district: 2, admin_post: 3, locality: 4,
|
||||
province: 1,
|
||||
district: 2,
|
||||
admin_post: 3,
|
||||
locality: 4,
|
||||
};
|
||||
const closestContextLevel = contextOnly
|
||||
? Math.max(0, ...areas.map((area) => administrativeLevel[area.location_type ?? ''] ?? 0))
|
||||
? Math.max(
|
||||
0,
|
||||
...areas.map(
|
||||
(area) =>
|
||||
administrativeLevel[
|
||||
area.location_type ?? ''
|
||||
] ?? 0,
|
||||
),
|
||||
)
|
||||
: 0;
|
||||
for (const area of areas) {
|
||||
const label = document.createElement('p');
|
||||
@@ -103,7 +116,9 @@ export default function InteractiveInvestmentMap({
|
||||
const extent = layer.getBounds();
|
||||
const focusBoundary = hasSelectedBoundary
|
||||
? area.selected_territory
|
||||
: !closestContextLevel || administrativeLevel[area.location_type ?? ''] === closestContextLevel;
|
||||
: !closestContextLevel ||
|
||||
administrativeLevel[area.location_type ?? ''] ===
|
||||
closestContextLevel;
|
||||
if (extent.isValid() && focusBoundary)
|
||||
bounds.push(
|
||||
[extent.getSouth(), extent.getWest()],
|
||||
|
||||
Reference in New Issue
Block a user