坐标高程图

Graph of elevation from coordinations

我想问你一件关于交互式地图和地理服务的事情。我需要从我的坐标点获取高度并构建高度图。 在 google 地图中它看起来像这样:

https://developers.google.com/maps/documentation/javascript/examples/elevation-paths

我没有找到这方面的任何例子。我该如何解决这个问题?

非常感谢。 最好的问候 Petr Tomasek

您可以通过 HERE RoutingService JS API 构建类似的海拔图,方法是将 routeRequestParamsreturnelevation 的值指定为 true,如以下代码片段所示:

var router = platform.getRoutingService();
var routeRequestParams = {
  mode: 'fastest;car',
  representation: 'display',
  waypoint0: '{lat, lng}', // Start of route
  waypoint1: '{lat, lng}', // End of route
  returnelevation: true
};
var onResult = function(result) {
  var route = result.response.route[0];
  /* Now, altitudes are the third values of the each shape point.
     Note: Shape points returned as strings.  */
  var elevation_list = route.shape.map(x => parseFloat(x.split(",")[2]));
  /* Now you can use the elevation_list as input data to 
     draw your elevation graph with any graph tool 
  */
};
var onError = function(error) {
  console.log(error);
};

router.calculateRoute(
  routeRequestParams,
  onResult,
  onError
);

使用海拔值,您可以使用任何 JS 图形库绘制海拔图。 检查路由 API:https://developer.here.com/documentation/maps/topics/routing.html