added labelXOffset and labelYOffset symbolizer properties. Thanks madair for the original patch, and thanks jlacroix for turning it into symbolizer properties so nicely. p=jlacroix, r=me (fixes #2312)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9755 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -356,6 +356,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* alignment. Valid values for horizontal alignment: "l"=left, "c"=center, "r"=right. Valid values for vertical
|
||||
* alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". The canvas renderer does not
|
||||
* support vertical alignment, it will always use "b".
|
||||
* labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label.
|
||||
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label.
|
||||
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
|
||||
* Default is false.
|
||||
* fontColor - {String} The font color for the label, to be provided like CSS.
|
||||
|
||||
@@ -178,7 +178,14 @@ OpenLayers.Renderer = OpenLayers.Class({
|
||||
}
|
||||
var rendered = this.drawGeometry(feature.geometry, style, feature.id);
|
||||
if(style.display != "none" && style.label && rendered !== false) {
|
||||
this.drawText(feature.id, style, feature.geometry.getCentroid());
|
||||
var location = feature.geometry.getCentroid();
|
||||
if(style.labelXOffset || style.labelYOffset) {
|
||||
xOffset = isNaN(style.labelXOffset) ? 0 : style.labelXOffset;
|
||||
yOffset = isNaN(style.labelYOffset) ? 0 : style.labelYOffset;
|
||||
var res = this.getResolution();
|
||||
location.move(xOffset*res, yOffset*res);
|
||||
}
|
||||
this.drawText(feature.id, style, location);
|
||||
} else {
|
||||
this.removeText(feature.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user