planRoute: function () {
// 构造一个完整的起点到终点的点数组
let nodesList = [];
nodesList.push(this.startPoint);// 放入起点
this.wayPointList.forEach((wayPoint) => {
nodesList.push(wayPoint);// 放入途径点
});
nodesList.push(this.endPoint);// 放入终点
//创建最佳路径分析服务实例
let findPathService = new NetworkAnalystService(this.transportationAnalystUrl);
//创建最佳路径分析参数实例
let resultSetting = new TransportationAnalystResultSetting({
returnEdgeFeatures: true,
returnEdgeGeometry: true,
returnEdgeIDs: true,
returnNodeFeatures: true,
returnNodeGeometry: true,
returnNodeIDs: true,
returnPathGuides: true,
returnRoutes: true
});
let analystParameter = new TransportationAnalystParameter({
resultSetting: resultSetting,
weightFieldName: "SmLength"
});
let findPathParameter = new FindPathParameters({
isAnalyzeById: false,
nodes: nodesList,
parameter: analystParameter
});
findPathService.findPath(findPathParameter, (serviceResult) => {
let result = serviceResult.result;
result.pathList.map((path) => {
this.route = L.geoJSON(path.route);
// 将路径显示到地图上
this.route.addTo(this.map);
});
});
}
我想使用L.polyline来渲染服务器返回的数据而不是使用geoJSON,polyline的实例化参数要求的是多个二维的坐标数组,但是我发现route中的坐标点是三个元素,我应该怎么使用服务器返回的数据并将其提供给polyline渲染