【发布时间】:2020-01-24 01:14:22
【问题描述】:
我有这个二维数组
"coordinates" : [
[
[
41.5311338460033,
-8.61901849508286
],
[
41.5311338460033,
-8.61851692199707
],
[
41.5312944769825,
-8.61851692199707
],
[
41.5312944769825,
-8.61901849508286
],
[
41.5311338460033,
-8.61901849508286
]
]
]
我正在尝试将其转换为
const paths = [
{ lat: 41.53113384600326, lng: -8.619018495082855 },
{ lat: 41.53113384600326, lng: -8.61851692199707 },
{ lat: 41.53129447698251, lng: -8.61851692199707 },
{ lat: 41.53129447698251, lng: -8.619018495082855 },
{ lat: 41.53113384600326, lng: -8.619018495082855 }
];
我正在尝试做这个方法
let test = this.props.places.places.map(place => {
place.location.coordinates.map((c,i) => {
console.log('MAP TEST', c);
return {
lat: c[i],
lng: c[i]
};
});
});
console.log 从我的两个文档中返回两个位置,但是当我进行控制台测试时,我收到了 num。 任何人都知道如何将该数组转换为 lat、lng 对象?
【问题讨论】:
标签: javascript arrays node.js reactjs