Defining a method:
drawFragment : function(pFRAGMENT) {
console.log(pFRAGMENT.coordinates);
var wPolygon = turf.polygon([pFRAGMENT.coordinates]);
},
results in a turf error in execution:
First and last Position are not equivalent.
The passed coordinates are (first and last pair are identical - as required):
[[8.543590974130666, 47.377830192117756],
[8.543672439897477, 47.377850806388665],
[8.543667400529785, 47.37788614972462],
[8.543582309906242, 47.37791046432616],
[8.543590974130666, 47.377830192117756]]
What's wrong here?
const data = turf.polygon(
[
[
[8.543590974130666, 47.377830192117756],
[8.543672439897477, 47.377850806388665],
[8.543667400529785, 47.37788614972462],
[8.543582309906242, 47.37791046432616],
[8.543590974130666, 47.377830192117756],
],
],
{ name: 'poly1' }
);
console.log(data);
I didn't get any errors. have a look https://stackblitz.com/edit/js-jzkxtn?file=index.js