公交路线规划可以根据起终点获取公交路线规划数据,并可以通过添加Polyline绘制出公交路线,效果图:
示例代码如下:
br: BusRoute = new BusRoute();// 获取公交路线规划br.getRouteLines(fromArr, toArr, (res: passpoints) => {try {let resultLine: Array<Latlng> = []let passpoints: Array<passpoint> = res.passpointslet passpoint: passpoint = passpoints[0]for (let i =0; i < passpoint.length; i++ ) {let path: Latlng = passpoint[i]let ll: Latlng = new Latlng(path.lat, path.lng)resultLine.push(ll)}// 绘制路线let polyline:Polyline = new Polyline({points: resultLine,fillcolor: '#a6f',width: 10,join: SysEnum.LineJoinType.ROUND,cap: SysEnum.LineCapType.BUTT,isThined: true,isGeodesic: true});this.mapController?.addOverlay(polyline);} catch (e) {}}, {})
上一篇
下一篇
本篇文章对您是否有帮助?