我想要获取到旅行商分析结果的线路,并通过添加地物,把线路数据添加到地图中,可是添进去的总是一个点数据,下边是我的代码
var curLine; //var pathFeature = new SuperMap.Feature.Vector(); //以动画效果显示分析结果 function addPath(result2) { if (j < result2.tspPathList[i].route.components[0].components.length) { var points = []; for (var k = 0; k < 2; k++) { if (result2.tspPathList[i].route.components[0].components[j + k]) { points.push(new SuperMap.Geometry.Point(result2.tspPathList[i].route.components[0].components[j + k].x, result2.tspPathList[i].route.components[0].components[j + k].y)); } } var pathFeature = new SuperMap.Feature.Vector(); curLine = new SuperMap.Geometry.LinearRing(points); pathFeature.geometry = curLine; //curline 是geometry //line = curLine; pathFeature.style = style; vectorLayer.addFeatures(pathFeature);//pathFeature是巡逻路径 //每隔0.01毫秒加载一条弧段 pathTime = setTimeout(function () { addPath(result2); }, 0.03 ); j++; } else { clearTimeout(pathTime); j = 0; i++; allScheme(result2); }//添加 function addXLFeature() { if (!curLine) { widgets.alert.showAlert("请先选择路径",true); return; } curLine.id = "100000"; var editFeatureParameter, editFeatureService, features = { fieldNames: [], fieldValues: [], geometry: curLine }; editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({ features: [features], editType: SuperMap.REST.EditType.ADD, returnContent: false }); editFeatureService = new SuperMap.REST.EditFeaturesService(url3, { eventListeners: { "processCompleted": addXLFeaturesProcessCompleted, "processFailed": processFailed } }); editFeatureService.processAsync(editFeatureParameter); }