坐标的高程图 [英] Graph of elevation from coordinations
问题描述
我想问您有关交互式地图和地理服务的一件事.我需要从协调点获取海拔高度并绘制高程图.在Google地图中,它看起来像这样:
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?
非常感谢.最好的问候彼得·托马塞克(Petr Tomasek)
Thank you very much. Best regards Petr Tomasek
推荐答案
您可以通过此处指定 routeRequestParams
更改为 true
,如以下代码段所示:
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
);
使用高程值,您可以使用任何JS图形库绘制高程图.检出路由API: https://developer.here.com/documentation/maps/topics/routing.html
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
这篇关于坐标的高程图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!