Minor coding style improvements.
This commit is contained in:
@@ -336,29 +336,29 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
// Push symbol scaling, translation and rotation onto the transformation stack in reverse order.
|
||||
// Don't forget to apply all canvas transformations to the hitContext canvas as well(!)
|
||||
this.canvas.save();
|
||||
if (this.hitDetection) this.hitContext.save();
|
||||
if (this.hitDetection) { this.hitContext.save(); }
|
||||
|
||||
// Step 3: place symbol at the desired location
|
||||
this.canvas.translate(p0,p1);
|
||||
if (this.hitDetection) this.hitContext.translate(p0,p1);
|
||||
if (this.hitDetection) { this.hitContext.translate(p0,p1); }
|
||||
|
||||
// Step 2a. rotate the symbol if necessary
|
||||
angle = deg2rad * style.rotation; // will be NaN when style.rotation is undefined.
|
||||
if (!isNaN(angle)) {
|
||||
this.canvas.rotate(angle);
|
||||
if (this.hitDetection) this.hitContext.rotate(angle);
|
||||
if (this.hitDetection) { this.hitContext.rotate(angle); }
|
||||
}
|
||||
|
||||
// // Step 2: scale symbol such that pointRadius equals half the maximum symbol dimension.
|
||||
scaling = 2.0 * style.pointRadius / Math.max(symbolBounds.getWidth(), symbolBounds.getHeight());
|
||||
this.canvas.scale(scaling,scaling);
|
||||
if (this.hitDetection) this.hitContext.scale(scaling,scaling);
|
||||
if (this.hitDetection) { this.hitContext.scale(scaling,scaling); }
|
||||
|
||||
// Step 1: center the symbol at the origin
|
||||
cx = symbolBounds.getCenterLonLat().lon;
|
||||
cy = symbolBounds.getCenterLonLat().lat;
|
||||
this.canvas.translate(-cx,-cy);
|
||||
if (this.hitDetection) this.hitContext.translate(-cx,-cy);
|
||||
if (this.hitDetection) { this.hitContext.translate(-cx,-cy); }
|
||||
|
||||
// Don't forget to scale stroke widths, because they are affected by canvas scale transformations as well(!)
|
||||
// Alternative: scale symbol coordinates manually, so stroke width scaling is not needed anymore.
|
||||
@@ -408,7 +408,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
|
||||
style.strokeWidth = unscaledStrokeWidth;
|
||||
this.canvas.restore();
|
||||
if (this.hitDetection) this.hitContext.restore();
|
||||
if (this.hitDetection) { this.hitContext.restore(); }
|
||||
this.setCanvasStyle("reset");
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user