From 2d219162384f2e2b2740c02b658b4ef1dec9b0b9 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Nov 2025 14:39:27 -0600 Subject: [PATCH] Improve JBS timber map --- map.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/map.html b/map.html index f811224..8baeb07 100644 --- a/map.html +++ b/map.html @@ -261,7 +261,11 @@ if (!feature || !feature.geometry) { return; } - const labelPoint = turf.pointOnFeature(feature); + // use center of mass when possible so labels stay visually centered + let labelPoint = turf.centerOfMass(feature); + if (!turf.booleanPointInPolygon(labelPoint, feature)) { + labelPoint = turf.pointOnFeature(feature); + } const [lng, lat] = labelPoint.geometry.coordinates; L.marker([lat, lng], { icon: L.divIcon({