首页 > 解决方案 > 构建多条路线,从 HERE 地图上的数组中获取端点

问题描述

我正在构建网络应用程序,它应该构建大量路线,并显示它们的距离。所有航线的起始航路点都是恒定的。我试着这样做

function calculateRouteFromAtoB (platform, end) {
    var router = platform.getRoutingService(),
        routeRequestParams = {
            mode: 'fastest;truck;traffic:enabled',
            height: '7',
            weightPerAxle: '4',
            trailersCount: '1',
            routeattributes : 'sh,bb,gr',
            dirtRoad: '-3',
            tollroad:'-3',
            //tunnelCategory: 'E',
            //maneuverattributes: 'direction,action',
            'waypoint0': '50.6431675,29.9479832', 
            'waypoint1': end  
        };

    router.calculateRoute(
        routeRequestParams,
        onSuccess,
        onError
    );
}

var tt;
for(tt=0;tt<array_with_endpoints.length;tt++){
    calculateRouteFromAtoB(platform,array_with_endpoints[tt]);
}

功能calculateRouteFromAtoB将路线添加到地图及其到面板的距离,但问题是面板上的路线长度与实际路线长度不匹配。我认为,端点是随机选择的。如果您知道如何使此代码按顺序选择端点,请告诉我。

标签: javascripthere-api

解决方案



推荐阅读