美文网首页
Turf 地图地理空间分析

Turf 地图地理空间分析

作者: 何亮hook_8285 | 来源:发表于2021-09-24 23:34 被阅读0次

简介

地理空间分析库,处理各种地图算法

效果图

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)

相关文章

网友评论

      本文标题:Turf 地图地理空间分析

      本文链接:https://www.haomeiwen.com/subject/fpjngltx.html