【问题标题】:Google Elevation API: Encoded polylineGoogle Elevation API:编码折线
【发布时间】:2018-02-06 23:13:14
【问题描述】:

是否可以通过客户端使用带有编码折线的 google Elevation API?

我知道有

https://maps.googleapis.com/maps/api/elevation/json?key=" + Meteor.settings.public.googleMaps + "&locations=enc:" + encodedPath

但这不适用于客户端,仅适用于服务器端。还是我弄错了?

我似乎无法让它通过电梯对象工作。

elevator.getElevationAlongPath({
   path: L.PolylineUtil.encode(path),
   samples: 256,
}, function(elevations, status) {

也没有

 elevator.getElevationForLocations({
   locations: L.PolylineUtil.encode(batch)
 },

错误信息是:

in property locations: not an Array

它适用于 LatLng 数组,但这对我的应用程序来说效率太低,因为我需要沿 1000 坐标路径的高程。

【问题讨论】:

    标签: javascript meteor google-maps-api-3 google-elevation-api


    【解决方案1】:

    您可以使用google.maps.geometry.encoding.encodePath(path:Array<LatLng>|MVCArray<LatLng>) 方法,它接受一个纬度数组并将它们编码成一条折线

    var polyline = google.maps.geometry.encoding.encodePath(yourLatlangArray);
    
    https://maps.googleapis.com/maps/api/elevation/json?key=" + 
    Meteor.settings.public.googleMaps + "&locations=enc:" + polyline
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 2011-07-10
      • 2014-05-15
      • 2012-10-12
      相关资源
      最近更新 更多