问题
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