Improve JBS timber map
This commit is contained in:
parent
c7ae50dc31
commit
2d21916238
1 changed files with 5 additions and 1 deletions
6
map.html
6
map.html
|
|
@ -261,7 +261,11 @@
|
||||||
if (!feature || !feature.geometry) {
|
if (!feature || !feature.geometry) {
|
||||||
return;
|
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;
|
const [lng, lat] = labelPoint.geometry.coordinates;
|
||||||
L.marker([lat, lng], {
|
L.marker([lat, lng], {
|
||||||
icon: L.divIcon({
|
icon: L.divIcon({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue