首页 / 浏览问题 / WebGIS / 问题详情
路径规划返回值结构和使用
27EXP 2023年08月16日
    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渲染

1个回答

你好,1、panth.route是路由对象类。 路由对象为一系列有序的带有属性值 M 的 x,y 坐标对,其中第三个元素 M 值为该结点的距离属性(到已知点的距离)。如果想用用L.polyline()方式绘制,就需要取出坐标串,自行构造二维坐标数组。

2、还有一种方式直接对iserver发请求 ,获取到route-lines-points所有坐标点[x,y],

参考帮助文档:http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iServer/mergedProjects/SuperMapiServerRESTAPI/root/networkanalyst/networkDataName/path.htm

1,865EXP 2023年08月16日
...