我在Angular Projects中使用Turf,版本:^ 5.1.6。我有一个点,我想将服务器检索到的JSON对象转换为FeatureCollection以找到最近的点。
我的意思是:
var targetPoint = turf.point([15.2849697, 41.6899772], {"marker-color": "#0F0"});
功能集示例展示
var points = turf.featureCollection([
turf.point([28.973865, 41.011122]),
turf.point([28.948459, 41.024204]),
turf.point([28.938674, 41.013324])
]);
var nearest = turf.nearestPoint(targetPoint, points);
在这种情况下,效果很好。 但是当我添加对象时:
var mypoints = turf.featureCollection(this.bus.features)
即使我在mypoint
和point
之间获得相同的结构,当我将mypoints添加到nearest
函数中时:
var nearest = turf.nearestPoint(targetPoint, mypoints);
我收到此错误:
Argument of type 'FeatureCollection<Geometry, { [name: string]: any; }>' is not assignable to parameter of type 'FeatureCollection<Point, { [name: string]: any; }>'
有人可以帮助我吗?