envelope
是一个Turf.js方法,用于计算多边形的外接矩形框。返回一个叫做 bbox
的包围盒,它包含了最小的外接矩形框。envelope
支持任何 任何类型的 GeoJSON Feature,包括基准点、线、多边形。
envelope(geojson)
geojson
: 任何类型的 GeoJSON Featurebbox
var square = turf.polygon([[
[-75.168, 39.952],
[-75.168, 39.954],
[-75.166, 39.954],
[-75.166, 39.952],
[-75.168, 39.952]
]]);
var bbox = turf.envelope(square);
// {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.168,39.952],[-75.168,39.954],[-75.166,39.954],[-75.166,39.952],[-75.168,39.952]]]}}