How to get bounding box based on distance from given point?

Viewed 2688

I need restrict map area to 5km radius around given point. How can I get appropriate bounding box using mapbox-gl-js or turf?

2 Answers

Buffer API has changed. Buffer's optional argument needs to be an object like so:

var point = turf.point([-90.548630, 14.616599]);
var buffered = turf.buffer(point, 5, {units:'kilometers'}); /// notice 'units'
var bbox = turf.bbox(buffered);
console.log(turf.bboxPolygon(bbox));
Related