Open SpyCop opened 2 years ago
Not using the Draw plugin, we can use turf.js
with their area()
function. Using the GeoMan toGeoJSON()
on the layer
from the pm:create
event:
map.on('pm:create', (e) => {
console.log(e);
// Add code here for handling creation of
var type = e.shape,
layer = e.layer;
if (type === 'Polygon') {
geoJSONFt = layer.toGeoJSON();
geoJSONFt.properties.area = turf.area(geoJSONFt);
console.log(geoJSONFt);
};
});
For area calculations there are several ways of displaying it:
It might be useful to add the calculated value to the database, but maybe it is also possible to just calculate the area every time based on the Points in the data base?