Improve JBS timber map

This commit is contained in:
Chandler Swift 2025-11-08 14:39:27 -06:00
parent c7ae50dc31
commit 2d21916238
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F

View file

@ -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({