I am trying to get the area measurements of polygons so I can list them in a table to the side of the map, next to the name of the polygon. This is what I have tried with n
L.GeometryUtil.geodesicArea(layer.getLatLngs())[0]
should get you the area.
But I ended up using leaflet-geoman-free
to do the drawing and use turf.js
to get the area.
map.pm.enableDraw('Polygon', {
snappable: true,
snapDistance: 20,
});
map.on('pm:create', e => {
const layer = e.layer
alert(turf.area(layer.toGeoJSON()))
});