0

我试图在圆的 30 度角上得到一个点,但不知道我必须尝试的具体事情。到目前为止,我尝试了两个示例 1) 通过应用公式获取角度:x = Xc + R * cos(angle) y = Yc + R * sin(angle)

代码 :

const radius1 = circle.getRadius();
    const cx = 29.505;
    const cy = 70.09;
    const radiusInKm = 500;
    const angleInDegrees = 90;
    // x = Xc + R * cos(theta)
    // y = Yc + R * sin(theta)
    const Xc = cx + radius1 * Math.cos(90);
    const Yc = cy + radius1 * Math.sin(90);
    let marker = L.marker([Xc, Yc]).addTo(this.map);

2)使用传单几何Utils代码:

 let A = L.marker([29.505, 70.09]).addTo(this.map);
    let B = geometry.destination(A.getLatLng(), angleInDegrees, radiusInKm * 1000);
    console.log(B.getLatLng());
    L.marker(B).addTo(this.map);

在代码导入之前是 *import * as L from 'leaflet'; 从'leaflet-geometryutil'导入{geometry};*

1 的问题在于它给出的结果为 Xc = 42574.68122670592 Yc = -15240.531055110834,而 2 的问题显示在浏览器的调试模式下,即“leaflet_geometryutil__WEBPACK_IMPORTED_MODULE_2__.geometry is undefined”

4

0 回答 0