fix map and stuff

This commit is contained in:
Jake Kasper
2025-08-22 15:49:00 -04:00
parent 89ee666858
commit 8049a72505
3 changed files with 67 additions and 11 deletions

View File

@@ -355,9 +355,27 @@ const PropertyMap = ({
{/* Existing sections */}
{sections.map((section) => {
if (!section.polygonData?.coordinates?.[0]) return null;
console.log('Section:', section);
// Handle both string and object polygon data
let polygonData = section.polygonData;
if (typeof polygonData === 'string') {
try {
polygonData = JSON.parse(polygonData);
} catch (e) {
console.error('Failed to parse polygon data:', e);
return null;
}
}
if (!polygonData?.coordinates?.[0]) {
console.log('No coordinates found for section:', section.id);
return null;
}
const coordinates = polygonData.coordinates[0].map(([lng, lat]) => [lat, lng]);
console.log('Mapped coordinates:', coordinates);
const coordinates = section.polygonData.coordinates[0].map(([lng, lat]) => [lat, lng]);
const isInternallySelected = selectedSection?.id === section.id;
const isExternallySelected = selectedSections.includes(section.id);
const isSelected = isInternallySelected || isExternallySelected;