Imran Rajjad | 3 Oct 2010 00:30
Picon

Re: [OpenLayers-Users] Re: add an arrow to line feature

Well I figured it out , instead of adding a line, add a collection of
geometry having a line and point.. set the shape of point to traigle
and calculate the rotation using simple atan(dy/dx). I will share the
code on Monday with you

regards,
Imran

On Fri, Oct 1, 2010 at 2:19 PM, Gagan Bansal
<gaganbansal123@...> wrote:
>
> Hi,
>
> I was also looking for this feature, i.e. showing the line direction. So
> based on Sveen suggestion I have written this example
>
> http://gaganb.wordpress.com/2010/09/30/draw-line-direction-on-openlayers-feature/
>
> Regards,
> Gagan
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/add-an-arrow-to-line-feature-tp5234002p5590646.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users@...
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>

--

-- 
(Continue reading)

Imran Rajjad | 6 Oct 2010 07:22
Picon

Re: [OpenLayers-Users] Re: add an arrow to line feature

ok this kinda worked for me...for putting an arrow on a line, now this
is a line..not a polyline.

I made this function little function
--------------------------
function getAngleofLine(pointList) //calculate angle for screen
{

// point list is an array of OpenLayers.Geometry.Point having two
points of a line

var startPt=map.getPixelFromLonLat(new
OpenLayers.LonLat(pointList[0].x,pointList[0].y));
var endPt=map.getPixelFromLonLat(new
OpenLayers.LonLat(pointList[1].x,pointList[1].y));
//in the above line I think it would work too if we use Coordinates
instead of Pixels, but I used pixel cause its easy to do the math with

       			
var dy=endPt.y - startPt.y;
var dx=endPt.x - startPt.x;
       			
var angle=Math.atan(dy/dx) / (Math.PI/180); //convert to degrees
       			
if(dx<0) // adjustment in angle for line moving to bottom
angle-=180; // switch direction..if I dont do this.. the traigle will
point in other direction in certain cases
     			  			
return angle;	
}
(Continue reading)


Gmane