【问题标题】:How can we convert path.td to array of latitude and longitude in google map api?我们如何将 path.td 转换为谷歌地图 api 中的纬度和经度数组?
【发布时间】:2021-11-16 09:10:20
【问题描述】:

我正在使用 geolib 计算折线的经纬度距离,但是在编辑和撤消折线后,我得到了不同格式的纬度和经度(你可以检查控制台),所以我无法计算距离.

参考堆栈闪电战网址:-https://stackblitz.com/edit/angular-draw-polygon-google-maps-pkharg?file=app%2Fapp.component.ts

请提前帮助我。

谢谢。

【问题讨论】:

    标签: angular typescript google-maps


    【解决方案1】:

    polyline.getPath 返回具有 lat lng 函数的 google.maps.LatLng 的 MVCArray。您需要将此数组映射到 lan lng 数字数组中

    _this.coordinates = path.getArray().map((p) => [p.lat(), p.lng()]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 1970-01-01
      相关资源
      最近更新 更多