In an SLD styling file for a line geometry, you can use the SVG parameters marker-start
and marker-end
to place an arrow head respectively at the start point and end point of a line.
With this approach, you cannot customize the type of the arrow head itself; the style of the arrow head is based on the SLD
stroke properties defined in the encompassing LineSymbolizer
.
<?xml version='1.0' encoding='UTF-8'?>
<FeatureTypeStyle xmlns="http://www.opengis.net/se"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/FeatureStyle.xsd http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd"
version="1.1.0">
<Rule>
<Name>Blue_Arrow_Line</Name>
<LineSymbolizer>
<Geometry>
<ogc:PropertyName>the_geom</ogc:PropertyName>
</Geometry>
<Stroke>
<SvgParameter name="stroke">#0000FF</SvgParameter>
<SvgParameter name="stroke-width">2</SvgParameter>
<SvgParameter name="marker-end">true</SvgParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
If you want full customizability of the arrow head, you can use a different approach: define the arrow head through an additional
PointSymbolizer
.
This approach allows you to either use a built-in icon, through Mark
, or a custom icon (SVG, PNG, …​), as your arrow head.
To determine the location of the arrow head, you can use the custom functions startPoint
and endPoint
inside the SLD Geometry
element.
They respectively return the first and last point of the referred geometry.
To align the arrow head with the geometry, you can use the custom functions startAngle
and endAngle
inside the SLD Rotation
element.
They respectively return the angle of the tangent at the first and last point of the referred geometry.
<?xml version='1.0' encoding='UTF-8'?>
<FeatureTypeStyle xmlns="http://www.opengis.net/se"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/se http://schemas.opengis.net/se/1.1.0/FeatureStyle.xsd http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/filter.xsd"
version="1.1.0">
<Rule>
<Name>Blue_Arrow_Line</Name>
<LineSymbolizer>
<Stroke>
<SvgParameter name="stroke">#0000FF</SvgParameter>
<SvgParameter name="stroke-width">2</SvgParameter>
</Stroke>
</LineSymbolizer>
<PointSymbolizer>
<Geometry>
<ogc:Function name="endPoint">
<ogc:PropertyName>the_geom</ogc:PropertyName>
</ogc:Function>
</Geometry>
<Graphic>
<Mark>
<WellKnownName>triangle</WellKnownName>
<Fill>
<SvgParameter name="fill">#0000FF</SvgParameter>
<SvgParameter name="fill-opacity">0.5</SvgParameter>
</Fill>
<Stroke>
<SvgParameter name="stroke">#0000FF</SvgParameter>
<SvgParameter name="stroke-width">2</SvgParameter>
</Stroke>
</Mark>
<Size>30</Size>
<Rotation>
<ogc:Function name="endAngle">
<ogc:PropertyName>the_geom</ogc:PropertyName>
</ogc:Function>
</Rotation>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>