I am using sharpmap to render my OPEN STREET MAPS (osm) maps. i need to show the direction of one way streets on my map. How can i do that?! After googling i found SharpMap.Rendering.Symbolizer and style.Line.DashPattern might help but i couldn't figure it how do it...! i have the oneway column in my data, and i can filter my data for one way streets for styling, but i don't know how to style and draw a small arrow on my lines.

i want the arrows like this picture Street Directions

  • Any Ideas???!!!
    – Mohy66
    May 25, 2015 at 4:54

2 Answers 2


OK, after a few days researching finally i solved my own question, and i'm going to share it for others! First of all, sharpmap doesn't have a built in functionality to show the direction of streets, so we have to style the roads! for drawing a small arrow on the roads you should use LineSymbolizer of vactor Style. below is the code i have written to do this:

        VectorStyle style = new VectorStyle();
        var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();
        //styling the road
        cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(Color.Gold, 3) });
        //drawing the arrow
        var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
            Pattern = getArrowedLine(),
            Line = new System.Drawing.Pen(System.Drawing.Color.Gray, 2),
            Interval = 70

        cls.ImmediateMode = true;
        style.LineSymbolizer = cls;

and the getArrowdLine function:

 private GraphicsPath getArrowedLine()
        //creating the Arrow graphics like this ->
        var gp = new GraphicsPath();
        gp.AddLine(5, 2, 7, 0); //     \
        gp.AddLine(0, 0, 7, 0); // -----
        gp.AddLine(5, -2, 7, 0);//     /
        //if you dont close the figure you will have continuesly arrows like this ->->->->->
        //but if you close it, depend on interval you will have ->   ->   ->
        return gp;

I am surprised why sharpmap did not implement ArrowedLine (which is commonly used in maps) in their WarpedLineSymbolizer class!!!


As the code posted here would not show up properly, here is a link: https://sharpmap.codeplex.com/SourceControl/latest#Branches/1.0/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs

  • Thank you FObermaier,but your code is incomplete!!!
    – Mohy66
    May 27, 2015 at 14:54

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.