简介
地理空间分析库,处理各种地图算法
效果图
image-20210924233219217.png引入
<script src="https://www.bootcdn.cn/Turf.js/"></script>
计算沿线的点
var line = turf.lineString([
[109.502991, 29.68718],
[108.837829, 32.969237],
[113.567871, 37.200787]
]);
var options = {units: 'miles'};
var along = turf.along(line, 300, options);
计算区域面积
var polygon = turf.polygon([[
[108.09876, 37.200787],
[106.398901, 33.648651],
[114.972103, 33.340483],
[113.715685, 37.845557],
[108.09876, 37.200787]
]]);
var area = turf.area(polygon);
计算边界框
var line = turf.lineString([
[104.99467, 30.071677],
[107.13797, 36.550462],
[112.607082, 34.991467]
]);
var bbox = turf.bbox(line);
var bboxPolygon = turf.bboxPolygon(bbox);
计算多边形
var bbox = [105.361046, 35.356724, 111.59974, 30.934089];
var poly = turf.bboxPolygon(bbox);
更多案例参考:Turf.js中文网 (fenxianglu.cn)
网友评论