I have a line layer in geoserver as in the 1st image.

How can I draw an arrow on the line like in the 2nd image?

The line.rar includes a shapefile and a sld file.

Can edit a sample for me?


enter image description here enter image description here


1 Answer 1


The GeoServer documentations states how to extract start and end points with geometry transformations (just use the end- point rule). The code example provided uses square as marks, but you could always replace this with e.g. the shape symbol shape://oarrow.

EDIT: I forgot to mention how to rotate the triangle correctly (couldn't find it in the documentation, but took it from page 38 in this presentation)!

<ogc:Function name="endAngle">

EDIT2: Just wanted to make sure everything works as described, here is a code sample based on GeoServer's default blue line SLD style:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
        xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
        <Name>Blue arrows</Name>
            <Title>A blue line with end arrows</Title>
                            <CssParameter name="stroke">#0000FF</CssParameter>
                            <CssParameter name="stroke-width">2</CssParameter>
                            <ogc:Function name="endPoint">
                                <CssParameter name="fill">#0000FF</CssParameter>
                                <CssParameter name="fill-opacity">0.5</CssParameter>
                                    <CssParameter name="stroke">#0000FF</CssParameter>
                                    <CssParameter name="stroke-width">2</CssParameter>
                                <ogc:Function name="endAngle">

This is how it should look like:

Blue Arrow Example image

  • SAnderka, thanks a lot. I use the edit2 way and it runs wonderful on geoserver.
    – user23048
    Commented Oct 10, 2014 at 3:11
  • There is a grey checkmark underneath this question's voting buttons. You need to click it (it'll turn green) to mark your question as answered in GIS SE's system. Thanks!
    – SAnderka
    Commented Oct 13, 2014 at 7:29
  • I've been trying to get this to work using CSS styles and cannot do it. Can anyone help with that? I though I was on to something with this but it does not work: [@scale > 1] { geometry: startPoint(geom); mark: symbol(triangle); mark-size:10px; }
    – ca0v
    Commented Apr 15, 2017 at 11:54
  • This may help if you're trying something like this in css: [@scale > 1] { mark-geometry: [startPoint(geom)]; mark: symbol(arrow); mark-size:10px; mark-rotation: [endAngle(geom)]; :mark { fill: white; stroke: black; } }
    – ca0v
    Commented Apr 15, 2017 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.