该Turf模块用于创建包含多个点的点集合。
通过npm进行安装:
npm install @turf/multi-point
import multiPoint from '@turf/multi-point';
const coordinates = [
[-77.032, 38.913],
[-122.414, 37.776],
[-77.206, 38.88]
];
const points = multiPoint(coordinates);
coordinates
(Array<Array<number>>): 一个由点坐标组成的数组,格式为 [[longitude, latitude], [longitude, latitude], ...]。函数将返回一个Turf Point类型的GeoJSON Feature对象。
const coordinates = [
[-77.032, 38.913],
[-122.414, 37.776],
[-77.206, 38.88]
];
const points = multiPoint(coordinates);
console.log(points);
输出结果:
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPoint",
"coordinates": [
[-77.032, 38.913],
[-122.414, 37.776],
[-77.206, 38.88]
]
}
}