答案 0 :(得分:0)
您的问题有两种解释。我将尝试同时回答这两个问题,以便您可以选择自己的打算。希望对您有帮助!
如何获取路线中每个链接的速度限制- 使用以下示例中给出的路由API。检查How to get SpeedLimit in HERE API
中的答案答案 1 :(得分:0)
为您的路由请求使用routeattributes:“ shape”,您可能会如下所示获得每个路段和相关的速度限制:
let route = res.body.response.route[0];
let legs = route.leg;
let links = [];
legs.forEach(leg => {
Object.assign(links, leg.link);
});
console.log("#links", links.length);
links.forEach(link => {
let sl = link.speedLimit; // in m/sec
let shape = link.shape; // shape to draw
let style = {
lineWidth: 4,
strokeColor: "yellow"
};
if (sl < 50 * 1000 / 3600)
style.strokeColor = "red";
else if (sl < 90 * 1000 / 3600)
style.strokeColor = "orange";
else
style.strokeColor = "green";
let line = new H.geo.LineString();
shape.forEach(latlng => {
let coord = latlng.split(",");
line.pushLatLngAlt(coord[0], coord[1]);
});
let polyline = new H.map.Polyline(line, {
style: style
});
/* group created previously as
group = new H.map.Group();
map.addObject(group);
*/
group.addObject(polyline);
});