Deck.gl文档具有一种非常奇怪的独特方法来处理其样本数据以获取经度和纬度列。
以下是其taxiData
集https://raw.githubusercontent.com/uber-common/vis-academy/master/src/demos/data/taxi.js
这是处理数据的代码。
_processData() {
const points = taxiData.reduce((accu, curr) => {
accu.push({
position: [Number(curr.pickup_longitude), Number(curr.pickup_latitude)],
pickup: true
});
accu.push({
position: [
Number(curr.dropoff_longitude),
Number(curr.dropoff_latitude)
],
pickup: false
});
return accu;
}, []);
this.setState({
points
});
}
这是我要处理的数据集,以便在deck.gl上绘制图形 https://raw.githubusercontent.com/pennytalalak/road-crash-data/master/src/data/road-data.js,但是当我用他们的示例代码替换数据集时,它给了我一个错误
_processData() {
const points = roadData.reduce((accu, curr) => {
accu.push({
position: [Number(curr.LONGITUDE), Number(curr.LATITUDE)],
pickup: true,
})
return accu
}, [])
this.setState({
points,
})
}