【发布时间】:2019-04-29 11:29:45
【问题描述】:
我有一些被 turfJs 卡住了,
我想获取父数组的所有元素, 并将它们设置为 FeatureCollection 我对所有数组进行迭代并将它们隔离, 但是当将它们传递给 FeatureCollection 时,它们只取最后一个而不是全部, 那么该怎么做呢?
这是我的数组“用户”
这里是featureCollection
功能
handleNearby = () => {
const { region, providers } = this.state;
let points = [];
providers.map((p, i) => {
console.log(p.coordinates);
console.log(i);
points = turf.point([p.coordinates.latitude, p.coordinates.longitude])
// console.log(points);
});
var collection = turf.featureCollection([points]);
console.log(collection);
console.log(providers);
// var targetPoint = turf.point([region.longitude, region.latitude]);
// var nearest = turf.nearestPoint(targetPoint, points);
// var addToMap = [targetPoint, points, nearest];
}
【问题讨论】:
-
提供一个最小且可测试的示例将帮助您更快地获得答案:stackoverflow.com/help/mcve
标签: javascript reactjs react-native geojson