Graph of elevation from coordinations

天大地大妈咪最大 提交于 2021-01-29 14:53:52

问题


I want ask you to one thing about interactive map and geo service. I need to get altitude from my coordinations points and build graph of elevation. In google maps it looks like this:

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

I didn't found any example for this. How can I solve this problematic?

Thank you very much. Best regards Petr Tomasek


回答1:


You can build a similar elevation graph via the HERE RoutingService JS API by specifying the value of returnelevation of the routeRequestParams to true like in this snippet:

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
);

With the elevation values you can draw your elevation graph with any JS graph library. Checkout the routing API: https://developer.here.com/documentation/maps/topics/routing.html



来源:https://stackoverflow.com/questions/55915199/graph-of-elevation-from-coordinations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!