openlayer获取长度和面积代码如下:
import {getArea, getLength} from 'ol/sphere';
//长度
const length = getLength(line);
//面积
const area = getArea(polygon);
实测后发现计算的面积总是趋近于0,上官网查看文档,接口有一个坐标系的参数,默认是3857,这不问题找到了么。

解决后代码:
const area = getArea(polygon, {
projection: "EPSG:4326",
});

385

被折叠的 条评论
为什么被折叠?



