Leaflet 我得到了bbox的两分

Leaflet 我得到了bbox的两分,leaflet,geojson,turfjs,Leaflet,Geojson,Turfjs,我正在尝试在后端移动客户端方法: 客户端方法是使用TurbJS和传单执行一些操作。唯一的问题是服务器端(nodejs)窗口不可用,因此我不能使用传单 我正在寻找一种方法来转换这段代码: const pointA=草皮点([originCoords.lng,originCoords.lat]); const pointB=turp.destination.default(pointA,50,45,{units:'km'}); //这是我用传单买的BBox 常量latLngBounds=L.latL

我正在尝试在后端移动客户端方法:

客户端方法是使用TurbJS和传单执行一些操作。唯一的问题是服务器端(nodejs)窗口不可用,因此我不能使用传单

我正在寻找一种方法来转换这段代码:

const pointA=草皮点([originCoords.lng,originCoords.lat]);
const pointB=turp.destination.default(pointA,50,45,{units:'km'});
//这是我用传单买的BBox
常量latLngBounds=L.latLngBounds(
L.latLng(点A.几何坐标[1],
pointA.geometry.坐标[0]),
L.latLng(点B.几何体坐标[1],点B.几何体坐标[0]),
);
//然后,我用那个BBox创建了矩形,同样是传单
平铺=L.矩形(板条边界);

我还是GeoJSON的新手,也许我遗漏了什么,有人能帮我吗

以下是仅使用Turf.JS的代码

var turf = require('@turf/turf');
var pointA = turf.point([-75.343, 39.984]);
var pointB = turf.destination(pointA, 50, 45, { units: 'kilometers' });
//create a bbox that extends to include all the features
var bbx = turf.bbox(turf.featureCollection([pointA, pointB]));
var pgn = turf.bboxPolygon(bbx);  //convert it to Polygon feature
console.log(JSON.stringify(pgn)); //output to console
输出:

{"type":"Feature","properties":{},
    "geometry":{
    "type":"Polygon",
    "coordinates":[[
        [-75.343,39.984],
        [-74.92609,39.984],
        [-74.92609,40.3012],
        [-75.343,40.3012],
        [-75.343,39.984]]]
    }
}
编辑1

添加运行代码的功能:

//var-turph=require('@turph/turph');
var pointA=草皮点([-75.343,39.984]);
var pointB=turf.destination(点A,50,45,{单位:'公里'});
//创建一个扩展到包含所有功能的bbox
var bbx=turp.bbox(turp.featureCollection([pointA,pointB]);
var pgn=草皮.bbx多边形(bbx)//将其转换为多边形要素
log(JSON.stringify(pgn))//输出到控制台