diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
index 1f997ed..fc06343 100644
--- a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
+++ b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
@@ -666,7 +666,7 @@ public class StyledMapRenderer extends AbstractMapRenderer {
         }
     }
 
-    public void drawNodeIcon(Node n, Image img, float alpha, boolean selected, boolean member) {
+    public void drawNodeIcon(Node n, Image img, float alpha, boolean selected, boolean member, double theta) {
         Point p = nc.getPoint(n);
 
         final int w = img.getWidth(null), h=img.getHeight(null);
@@ -677,7 +677,9 @@ public class StyledMapRenderer extends AbstractMapRenderer {
         if (alpha != 1f) {
             g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
         }
+        g.rotate(theta, p.x, p.y);
         g.drawImage(img, p.x-w/2, p.y-h/2, nc);
+        g.rotate(-theta, p.x, p.y);
         g.setPaintMode();
         if (selected || member)
         {
diff --git a/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java b/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
index 47a0a6c..30cef80 100644
--- a/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
+++ b/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
@@ -12,12 +12,15 @@ import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider;
 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
+import org.openstreetmap.josm.tools.Geometry;
+import org.openstreetmap.josm.tools.SubclassFilteredCollection;
 import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -25,6 +28,7 @@ import org.openstreetmap.josm.tools.Utils;
  */
 public class NodeElemStyle extends ElemStyle implements StyleKeys {
     public final MapImage mapImage;
+    public final IconRotation mapImageAngle;
     public final Symbol symbol;
 
     private Image enabledNodeIcon;
@@ -96,10 +100,59 @@ public class NodeElemStyle extends ElemStyle implements StyleKeys {
     public static final StyleList DEFAULT_NODE_STYLELIST = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE);
     public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE, BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE);
 
-    protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index) {
+    /**
+     * Determines how an icon is to be rotated depending on the primitive to displayed.
+     */
+    public static abstract class IconRotation {
+        /**
+         * Calculates the rotation angle depending on the primitive to displayed.
+         */
+        public abstract double getRotationAngle(OsmPrimitive p);
+
+        /**
+         * Always returns the fixed {@code angle}.
+         */
+        public static IconRotation buildStaticRotation(final double angle) {
+            return new IconRotation() {
+                @Override
+                public double getRotationAngle(OsmPrimitive p) {
+                    return angle;
+                }
+            };
+        }
+
+        /**
+         * Computes the angle depending on the referencing way segment, or {@code 0} if none exists.
+         */
+        public static IconRotation buildWayDirectionRotation() {
+            return new IconRotation() {
+                @Override
+                public double getRotationAngle(OsmPrimitive p) {
+                    if (!(p instanceof Node)) {
+                        return 0;
+                    }
+                    final Node n = (Node) p;
+                    final SubclassFilteredCollection<OsmPrimitive, Way> ways = Utils.filteredCollection(n.getReferrers(), Way.class);
+                    if (ways.isEmpty()) {
+                        return 0;
+                    }
+                    final Way w = ways.iterator().next();
+                    final int idx = w.getNodes().indexOf(n);
+                    if (idx == 0) {
+                        return -Geometry.getSegmentAngle(n.getEastNorth(), w.getNode(idx + 1).getEastNorth());
+                    } else {
+                        return -Geometry.getSegmentAngle(w.getNode(idx - 1).getEastNorth(), n.getEastNorth());
+                    }
+                }
+            };
+        }
+    }
+
+    protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index, IconRotation iconRotation) {
         super(c, default_major_z_index);
         this.mapImage = mapImage;
         this.symbol = symbol;
+        this.mapImageAngle = iconRotation;
     }
 
     public static NodeElemStyle create(Environment env) {
@@ -114,13 +167,22 @@ public class NodeElemStyle extends ElemStyle implements StyleKeys {
         if (mapImage == null) {
             symbol = createSymbol(env);
         }
+        final IconRotation iconRotation;
+        final Float rotationFloat = c.get("icon-rotation", null, Float.class);
+        if (rotationFloat != null) {
+            iconRotation = IconRotation.buildStaticRotation(Math.toRadians(rotationFloat));
+        } else if ("way".equalsIgnoreCase(c.get("icon-rotation", null, String.class))) {
+            iconRotation = IconRotation.buildWayDirectionRotation();
+        } else {
+            iconRotation = null;
+        }
 
         // optimization: if we neither have a symbol, nor a mapImage
         // we don't have to check for the remaining style properties and we don't
         // have to allocate a node element style.
         if (!allowDefault && symbol == null && mapImage == null) return null;
 
-        return new NodeElemStyle(c, mapImage, symbol, default_major_z_index);
+        return new NodeElemStyle(c, mapImage, symbol, default_major_z_index, iconRotation);
     }
 
     public static MapImage createIcon(final Environment env, final String[] keys) {
@@ -258,7 +320,8 @@ public class NodeElemStyle extends ElemStyle implements StyleKeys {
                     }
                     nodeIcon = enabledNodeIcon;
                 }
-                painter.drawNodeIcon(n, nodeIcon, Utils.color_int2float(mapImage.alpha), selected, member);
+                painter.drawNodeIcon(n, nodeIcon, Utils.color_int2float(mapImage.alpha), selected, member,
+                        mapImageAngle == null ? 0.0 : mapImageAngle.getRotationAngle(primitive));
             } else if (symbol != null) {
                 Color fillColor = symbol.fillColor;
                 if (fillColor != null) {
