I am having trouble with getting the data for turf.centerOfMass() correct.
I have a featureCollection which can have multiple polygons added to it.
var polygonlines = [];
//add to polygons etc..
if (polygonlines.length >= 4) {
var feature =
{
"type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [polygonlines] }
}
features.push(feature);
}
}
});
}
var featCollection = {
type: 'FeatureCollection',
features: features
}
I want to calculate the centroid, center and the centerOfMass.
var centroid = turf.centroid(featCollection); //WORKS CORRECTLY
var centre = turf.center(featCollection); //WORKS CORRECTLY
var centreofMass = turf.centerOfMass(featCollection); //FAILS
The centerOfMass calculation fails and give me the error: "Uncaught TypeError TypeError: Qt is not a constructor"
The only way i can get centerOfMass to not fail is to list an individual polygon from the featcollection... but this is not what i want, i want the center for multiple polygons. The turf documentation says centerOfMass can take a FeatureCollection, centre and centroid do and they work fine...
How do I get it to get the centerOfMass for multiple polygons?
Thank you very much
Upgrade to leaflet version 7.0 seemed to fix the problem