I have this pice of code:
and I'm getting this result:
The centroids are not in center of parcels, and some are outside their parcels.
There is no point in publishing all code (I can do that on request), but changing this line:
for ilustrating the center of the extent of the parcel instead of the centroid give better results:
Note that this is not a good solution:
I have added the extent for the last two parcels to show that the centre of the extent is not the desired solution, but this is a lot better solution that the getCentroid function the way I got it.