[OpenLayers-Users] I want curved and arrowheaded lines as vectors on OSM layer

Jean-François Gigand jf at geonef.fr
Fri Aug 26 11:22:28 EDT 2011


Hi,

If lines are big enough in term of geodesic length, you can use the
algorithm in this example (thanks to the author!). It makes any
straigt line curved by following the shortest geodesic line:
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/gc_example.html

It works by creating a LineString geometry out of 2 points: the curved
look is achieved through many smaller straight lines.

Michael: getVertices() seems to be the right method to use. I just
checked the source, and when invoked with 'true'; returns directly the
first and last point components. Thanks for the indication, I was
doing the job myself. You may however optimize it a little bit by
calling it once:
   var endVertices = coursePath.geometry.getVertices (true);
   myGraf = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point (endVertices[1].x, endVertices[1].y),{ //
...


Jean-François Gigand - Geonef
Paris, France - http://geonef.fr/



2011/8/26 Michael <mdm at yachtpc.com>:
> I have drawn line ends by creating a vector feature and placing on top of
> the end of the line.  Any shape you want.  It's a little more
> time-consuming, but you can rotate the arrowhead after calculating the slope
> of the last segment of the line.
>
> Here is a snippet of code used to add a graphic to the end of the line,  in
> this case a predefined circle
>
>    var myGraf;
>    myGraf = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point
> (coursePath.geometry.getVertices
> (true)[1].x,coursePath.geometry.getVertices(true)[1].y),{
>        graphicName: "circle"
>    });
>    posLayer.addFeatures([myGraf]);
>
> I use getVertices to find the endpoint of the line.  If you have better
> access to that datum, it would save a few cycles.
>
> Michael
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>


More information about the Users mailing list