来自协调的标高图

时间:2019-04-30 06:37:01

标签: here-api

我想问您有关交互式地图和地理服务的一件事。我需要从协调点获取海拔高度并绘制高程图。 在Google地图中,它看起来像这样:

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

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

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

1 个答案:

答案 0 :(得分:1)

您可以通过HERE RoutingService JS API通过将routeRequestParamstrue的{​​{1}}的值指定来构建类似的海拔图,如下例所示:

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