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:
ahocevar
2009-10-24 04:41:36 +00:00
parent fd514e8435
commit 839348a3b2
3 changed files with 30 additions and 3 deletions

View File

@@ -33,7 +33,9 @@
fontSize: "12px",
fontFamily: "Courier New, monospace",
fontWeight: "bold",
labelAlign: "${align}"
labelAlign: "${align}",
labelXOffset: "${xOffset}",
labelYOffset: "${yOffset}"
}}),
renderers: renderer
});
@@ -83,6 +85,22 @@
favColor: 'black',
align: 'rt'
});
// Create a point feature to show the label offset options
var labelOffsetPoint = new OpenLayers.Geometry.Point(-101.04, 35.68);
var labelOffsetFeature = new OpenLayers.Feature.Vector(labelOffsetPoint);
labelOffsetFeature.attributes = {
name: "offset",
age: 22,
favColor: 'blue',
align: "cm",
// positive value moves the label to the right
xOffset: 50,
// negative value moves the label down
yOffset: -15
};
var nullFeature = new OpenLayers.Feature.Vector(null);
nullFeature.attributes = {
name: "toto is some text about the world",
@@ -94,7 +112,7 @@
map.addLayer(vectorLayer);
vectorLayer.drawFeature(multiFeature);
map.setCenter(new OpenLayers.LonLat(point.x, point.y), 3);
vectorLayer.addFeatures([pointFeature, polygonFeature, multiFeature, nullFeature ]);
vectorLayer.addFeatures([pointFeature, polygonFeature, multiFeature, labelOffsetFeature, nullFeature ]);
}
</script>
</head>