arcgis api for flex求線段的起點,終點和中點

眼鏡333發表於2018-01-12
求線段的中點:
先獲取Polyline最中間的path,然後再得到這個path的中間點作為整個Polyline的中點
private function getCenter(pl:Polyline):MapPoint{
    var pathCount:Number=pl.paths.length;
    var pathIndex:int=int((pathCount / 2) - 1);
    var midPath:Array=pl.paths[pathIndex];
    var ptCount:Number=midPath.length;
    var ptIndex:int=int((ptCount / 2) - 1);
    var pt:MapPoint=pl.getPoint(pathIndex, ptIndex);
    return pt;
}

求線段的起點和終點:
var xx:int=LuduanList.selectedIndex;
				var myGraphic:Graphic=GraphicArr[xx];
				var l:Polyline=myGraphic.geometry as Polyline;
				
				
				var goldPath:Array=l.paths[l.paths.length-1];
				
				var spt:MapPoint=l.getPoint(0,0);
				
				
				
				
				
				var mpt:MapPoint=l.getPoint(l.paths.length-1,goldPath.length-1);

相關文章