Arrow Symbol not align to right direction

433
0
10-27-2018 04:33 AM
ShaikhRizuan
New Contributor III

Hi,

I am trying the plot the arrow symbols along the direction of the line, but its not working properly. PFB image 

one arrow symbols shows correct direction but other do not, PFB code for getting the angle:

//Create Line from two points

var line = new Polyline();
line.addPath([pt1,pt]);
var lineGraphics = map.graphics.add(new Graphic(line,lineSymbol ));
lineGraphics.setGeometry(line);

//Get mid point of a line
var midPoint = lineGraphics._extent.getCenter();

//Get angle for the line
var angle = this._getAngle(lineGraphics.geometry.paths[0][0],lineGraphics.geometry.paths[0][1]);
var picSymbol= new PictureMarkerSymbol();
picSymbol.setUrl("css/images/filled-arrow.png");
picSymbol.setHeight(12);
picSymbol.setWidth(12)
picSymbol.setAngle(angle);
map.graphics.add(new Graphic(midPoint,picSymbol));

/////////////////////////////////////////////////////////

_getAngle:function(p1,p2){
var srtPnt = p2[1]-p1[1];
var endPnt= p2[0]-p1[0];
var angle =((180/Math.PI)* Math.atan2(srtPnt,endPnt));
return angle-180;
}

What changes need to be done to get proper angle?

Regards,

Shaikh

0 Kudos
0 Replies