定义方法:
drawFragment : function(pFRAGMENT) {
console.log(pFRAGMENT.coordinates);
var wPolygon = turf.polygon([pFRAGMENT.coordinates]);
},
导致执行时出现草皮错误:
第一个和最后一个位置并不等效。
传递的坐标是(第一对和最后一对是相同的-根据需要):
[[8.543590974130666, 47.377830192117756],
[8.543672439897477, 47.377850806388665],
[8.543667400529785, 47.37788614972462],
[8.543582309906242, 47.37791046432616],
[8.543590974130666, 47.377830192117756]]
怎么了?
参见
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);
我没有得到任何错误。看一看https://stackblitz.com/edit/js-jzkxtn?file=index.js