From 50b41f93f3736716eb26fcb3184aa40fca8c7954 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 20 Dec 2013 23:34:28 +0100 Subject: [PATCH] Correct calculation of ol.style.Circle canvas size --- src/ol/style/circlestyle.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index 98b2c0a48b..30448d8f39 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -5,6 +5,7 @@ goog.provide('ol.style.Circle'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('ol.color'); +goog.require('ol.render.canvas'); goog.require('ol.style.Fill'); goog.require('ol.style.Image'); goog.require('ol.style.ImageState'); @@ -114,12 +115,19 @@ ol.style.Circle.prototype.load = goog.nullFunction; */ ol.style.Circle.prototype.render_ = function() { var canvas = this.canvas_; - var size = 2 * this.radius_ + 1; - if (!goog.isNull(this.stroke_) && goog.isDef(this.stroke_.width)) { - size += this.stroke_.width; + var strokeWidth; + if (goog.isNull(this.stroke_)) { + strokeWidth = 0; + } else { + strokeWidth = this.stroke_.getWidth(); + if (!goog.isDef(strokeWidth)) { + strokeWidth = ol.render.canvas.defaultLineWidth; + } } + var size = 2 * (this.radius_ + strokeWidth) + 1; + canvas.height = size; canvas.width = size; @@ -134,8 +142,7 @@ ol.style.Circle.prototype.render_ = function() { if (!goog.isNull(this.stroke_)) { var strokeColor = this.stroke_.getColor(); context.strokeStyle = ol.color.asString(strokeColor); - var strokeWidth = this.stroke_.getWidth(); - context.lineWidth = goog.isDef(strokeWidth) ? strokeWidth : 1; + context.lineWidth = strokeWidth; context.stroke(); }