this.paths = [175, 179];
var params = new TransferSolutionParameters({
solutionCount: 6, // 最大换乘导引数量
transferTactic: "LESS_TIME", // 公交换乘策略类型
walkingRatio: 10, // 步行与公交的消耗权重比
points: [175, 179] // 起始点坐标
});
// 向服务器发送请求,并获取返回的结果
new TrafficTransferAnalystService(serviceUrl)
.analysisTransferSolution(params, function (serviceResult) {
// 获取服务端返回的结果
var result = serviceResult.result;
var items = result.defaultGuide.items;
for (var itemIndex = 0, itemLen = items.length; itemIndex < itemLen; itemIndex++) {
var geometry = items[itemIndex].route;
var pointsList = [];
for (var k = 0; k < geometry.points.length; k++) {
pointsList.push([geometry.points[k].x, geometry.points[k].y]);
}
console.log(pointsList)
var roadLine = new LineString(pointsList);
roadSourceLayer.addFeatures([new Feature(roadLine)]);
this.roadResultLayer = new VectorLayer({
source: roadSourceLayer,
style: new Style({
stroke: new Stroke({
color: 'dodgerblue',
width: 3
})
})
});
this.map.addLayer(this.roadResultLayer);
}
});