驾车路线规划可以根据起终点获取驾车路线规划数据,并可以通过添加Polyline绘制出驾车路线,效果图:
let option: DrivingRoutePlanOption = {mFrom: PlanNode.withLocation(fromArr),mTo: PlanNode.withLocation(toArr)}RoutePlanSearch.newInstance().drivingSearch(option).then((res: DrivingRouteResult) => {let resultLine: Array<LatLng> = []if (typeof res.routeLines === "undefined") {return}let line = res.routeLines[0]let steps = line.stepsfor (let i = 0; i < steps.length; i++) {let step = steps[i]step.pathList.forEach(element => {resultLine.push(element)})}let polyline = new Polyline({points: resultLine,fillcolor: '#6af',width: 10,join: SysEnum.LineJoinType.ROUND,cap: SysEnum.LineCapType.ROUND,isThined: true,isGeodesic: true});this.map?.addOverlay(polyline);})
上一篇
下一篇
本篇文章对您是否有帮助?