[OpenLayers-Users] Rotating point on a line (Vector features)

Tom Colley tomcolley at gmail.com
Tue Jan 21 03:43:37 PST 2014


Hi Everyone



I have some styling to do in OpenLayers that is proving to be a challenge
for me.



I have an incident management map that is used to draw features. One of the
features that needs to be drawn is a cordon (polygon) around the incident.
Access and exit points can be added to the cordon boundary (on a separate
point layer). For clarity these points need to be displayed as arrows
pointing onto the line, from inside for exit points and from outside for
access points. The image in the link below shows what I mean.



http://tinypic.com/view.php?pic=15g2ep&s=5#.Ut4tVvvFKUk



The bit I’m struggling with is how to rotate a point based on the line it
is being placed on top of.



I have set up snapping so that the point is snapped to the edge of the line.



I am currently using an SLD file to set the stylemap of the vector layers.



I thought if I could retrieve 2 vertices from the line closest to my point
I could calculate the angle of the line at that point and use that to set
the rotation value, stored as an attribute to be used by the SLD.



I’ve looked at the distanceTo function of OpenLayers Geometries but that
looks like it will only return the closest vertex from the line, I couldn’t
figure out a way of getting the second closest, and also thought that it’s
not as simple as 2 closest as they might both be one side of my point. What
I really need is the closest point on either side to get an angle.



At this point I thought I’d ask to see if anybody had any better ideas on a
way to do this, or if it’s even doable!



I would be very grateful for any suggestions from people.



Thanks



Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140121/f947a559/attachment.html>


More information about the Users mailing list