Merge pull request #944 from Karamell/labelOutlineOpacity2

added a labelOutlineOpacity attribute to SVG and Canvas Renderers.
This commit is contained in:
ahocevar
2013-04-22 00:53:30 -07:00
3 changed files with 6 additions and 1 deletions

View File

@@ -422,7 +422,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
* Default is false.
* labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.
* labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas & SVG renderers.
* labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.
* labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.
* fontColor - {String} The font color for the label, to be provided like CSS.
* fontOpacity - {Number} Opacity (0-1) for the label
* fontFamily - {String} The font family for the label, to be provided like in CSS.

View File

@@ -712,6 +712,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
for (var i = 0; i < numRows; i++) {
if (style.labelOutlineWidth) {
this.canvas.save();
this.canvas.globalAlpha = style.labelOutlineOpacity || style.fontOpacity || 1.0;
this.canvas.strokeStyle = style.labelOutlineColor;
this.canvas.lineWidth = style.labelOutlineWidth;
this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i) + 1);

View File

@@ -655,6 +655,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
outlineStyle.fontColor = outlineStyle.labelOutlineColor;
outlineStyle.fontStrokeColor = outlineStyle.labelOutlineColor;
outlineStyle.fontStrokeWidth = style.labelOutlineWidth;
if (style.labelOutlineOpacity) {
outlineStyle.fontOpacity = style.labelOutlineOpacity;
}
delete outlineStyle.labelOutlineWidth;
this.drawText(featureId, outlineStyle, location);
}