From 2d74a6b10f02090d8111b5db27fccb29d858c116 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 28 Nov 2014 12:56:14 +0100 Subject: [PATCH] Use lineDash in ol.style.Circle's and ol.style.RegularShape's stroke --- src/ol/style/circlestyle.js | 11 ++++++++++- src/ol/style/regularshapestyle.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index 0d209ba876..8901d8362b 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -3,6 +3,7 @@ goog.provide('ol.style.Circle'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('ol.color'); +goog.require('ol.has'); goog.require('ol.render.canvas'); goog.require('ol.style.Fill'); goog.require('ol.style.Image'); @@ -197,7 +198,7 @@ ol.style.Circle.prototype.unlistenImageChange = goog.nullFunction; */ ol.style.Circle.prototype.render_ = function() { var canvas = this.canvas_; - var strokeStyle, strokeWidth; + var strokeStyle, strokeWidth, lineDash; if (goog.isNull(this.stroke_)) { strokeWidth = 0; @@ -229,6 +230,10 @@ ol.style.Circle.prototype.render_ = function() { } if (!goog.isNull(this.stroke_)) { context.strokeStyle = strokeStyle; + lineDash = this.stroke_.getLineDash(); + if (ol.has.CANVAS_LINE_DASH && !goog.isNull(lineDash)) { + context.setLineDash(lineDash); + } context.lineWidth = strokeWidth; context.stroke(); } @@ -253,6 +258,10 @@ ol.style.Circle.prototype.render_ = function() { context.fill(); if (!goog.isNull(this.stroke_)) { context.strokeStyle = strokeStyle; + lineDash = this.stroke_.getLineDash(); + if (ol.has.CANVAS_LINE_DASH && !goog.isNull(lineDash)) { + context.setLineDash(lineDash); + } context.lineWidth = strokeWidth; context.stroke(); } diff --git a/src/ol/style/regularshapestyle.js b/src/ol/style/regularshapestyle.js index 74850f1225..c699fcadfe 100644 --- a/src/ol/style/regularshapestyle.js +++ b/src/ol/style/regularshapestyle.js @@ -3,6 +3,7 @@ goog.provide('ol.style.RegularShape'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); goog.require('ol.color'); +goog.require('ol.has'); goog.require('ol.render.canvas'); goog.require('ol.style.Fill'); goog.require('ol.style.Image'); @@ -215,7 +216,7 @@ ol.style.RegularShape.prototype.unlistenImageChange = goog.nullFunction; */ ol.style.RegularShape.prototype.render_ = function() { var canvas = this.canvas_; - var strokeStyle, strokeWidth; + var strokeStyle, strokeWidth, lineDash; if (goog.isNull(this.stroke_)) { strokeWidth = 0; @@ -257,6 +258,10 @@ ol.style.RegularShape.prototype.render_ = function() { } if (!goog.isNull(this.stroke_)) { context.strokeStyle = strokeStyle; + lineDash = this.stroke_.getLineDash(); + if (ol.has.CANVAS_LINE_DASH && !goog.isNull(lineDash)) { + context.setLineDash(lineDash); + } context.lineWidth = strokeWidth; context.stroke(); } @@ -290,6 +295,10 @@ ol.style.RegularShape.prototype.render_ = function() { context.fill(); if (!goog.isNull(this.stroke_)) { context.strokeStyle = strokeStyle; + lineDash = this.stroke_.getLineDash(); + if (ol.has.CANVAS_LINE_DASH && !goog.isNull(lineDash)) { + context.setLineDash(lineDash); + } context.lineWidth = strokeWidth; context.stroke(); }