Basic support for canvas only (patch from trac #3503)
This commit is contained in:
@@ -419,6 +419,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
|||||||
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.
|
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.
|
||||||
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
|
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
|
||||||
* Default is false.
|
* Default is false.
|
||||||
|
* labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas renderer.
|
||||||
|
* labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas renderer.
|
||||||
* fontColor - {String} The font color for the label, to be provided like CSS.
|
* fontColor - {String} The font color for the label, to be provided like CSS.
|
||||||
* fontOpacity - {Number} Opacity (0-1) for the label
|
* fontOpacity - {Number} Opacity (0-1) for the label
|
||||||
* fontFamily - {String} The font family for the label, to be provided like in CSS.
|
* fontFamily - {String} The font family for the label, to be provided like in CSS.
|
||||||
|
|||||||
@@ -527,7 +527,9 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
|||||||
drawText: function(location, style) {
|
drawText: function(location, style) {
|
||||||
style = OpenLayers.Util.extend({
|
style = OpenLayers.Util.extend({
|
||||||
fontColor: "#000000",
|
fontColor: "#000000",
|
||||||
labelAlign: "cm"
|
labelAlign: "cm",
|
||||||
|
labelOutlineColor: "white",
|
||||||
|
labelOutlineWidth: 3
|
||||||
}, style);
|
}, style);
|
||||||
var pt = this.getLocalXY(location);
|
var pt = this.getLocalXY(location);
|
||||||
|
|
||||||
@@ -560,6 +562,13 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
|||||||
this.canvas.measureText('xx').width;
|
this.canvas.measureText('xx').width;
|
||||||
pt[1] += lineHeight*vfactor*(numRows-1);
|
pt[1] += lineHeight*vfactor*(numRows-1);
|
||||||
for (var i = 0; i < numRows; i++) {
|
for (var i = 0; i < numRows; i++) {
|
||||||
|
if (style.labelOutlineWidth) {
|
||||||
|
this.canvas.save();
|
||||||
|
this.canvas.strokeStyle = style.labelOutlineColor;
|
||||||
|
this.canvas.lineWidth = style.labelOutlineWidth;
|
||||||
|
this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i));
|
||||||
|
this.canvas.restore();
|
||||||
|
}
|
||||||
this.canvas.fillText(labelRows[i], pt[0], pt[1] + (lineHeight*i));
|
this.canvas.fillText(labelRows[i], pt[0], pt[1] + (lineHeight*i));
|
||||||
}
|
}
|
||||||
} else if (this.canvas.mozDrawText) {
|
} else if (this.canvas.mozDrawText) {
|
||||||
|
|||||||
Reference in New Issue
Block a user