Index: trunk/src/org/openstreetmap/josm/gui/MapViewState.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapViewState.java	(revision 11469)
+++ trunk/src/org/openstreetmap/josm/gui/MapViewState.java	(revision 11470)
@@ -381,4 +381,20 @@
         }
         return Main.getProjection().latlon2eastNorth(b.getCenter());
+    }
+
+    /**
+     * Check if this MapViewState equals another one, disregarding the position
+     * of the JOSM window on screen.
+     * @param other the other MapViewState
+     * @return true if the other MapViewState has the same size, scale, position and projection,
+     * false otherwise
+     */
+    public boolean equalsInWindow(MapViewState other) {
+        return other != null &&
+                this.viewWidth == other.viewWidth &&
+                this.viewHeight == other.viewHeight &&
+                this.scale == other.scale &&
+                Objects.equals(this.topLeft, other.topLeft) &&
+                Objects.equals(this.projecting, other.projecting);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 11469)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 11470)
@@ -39,4 +39,5 @@
 import org.openstreetmap.josm.data.preferences.ColorProperty;
 import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.MapViewState;
 import org.openstreetmap.josm.io.CachedFile;
 import org.openstreetmap.josm.tools.ColorScale;
@@ -139,6 +140,5 @@
     // some cached values
     Rectangle heatMapCacheScreenBounds = new Rectangle();
-    int heatMapCacheVisibleSegments;
-    double heatMapCacheZoomScale;
+    MapViewState heatMapMapViewState;
     int heatMapCacheLineWith;
 
@@ -538,5 +538,5 @@
 
             // force redraw of image
-            heatMapCacheVisibleSegments = 0;
+            heatMapMapViewState = null;
         }
 
@@ -1088,5 +1088,6 @@
         // get bounds of screen image and projection, zoom and adjust input parameters
         final Rectangle screenBounds = new Rectangle(mv.getWidth(), mv.getHeight());
-        final double zoomScale = mv.getScale();
+        final MapViewState mapViewState = mv.getState();
+        final double zoomScale = mapViewState.getScale();
 
         // adjust global settings ( zero = default line width )
@@ -1117,6 +1118,5 @@
 
         // recalculation of image needed
-        final boolean imageRecalc = heatMapCacheVisibleSegments != visibleSegments.size() ||
-                                    heatMapCacheZoomScale != zoomScale ||
+        final boolean imageRecalc = !mapViewState.equalsInWindow(heatMapMapViewState) ||
                                     heatMapCacheLineWith != globalLineWidth;
 
@@ -1141,6 +1141,5 @@
 
             // remember draw parameters
-            heatMapCacheVisibleSegments = visibleSegments.size();
-            heatMapCacheZoomScale = zoomScale;
+            heatMapMapViewState = mapViewState;
             heatMapCacheLineWith = globalLineWidth;
         }
