Merge pull request #7454 from ahocevar/text-background-padding

Add text background rendering and text padding
This commit is contained in:
Andreas Hocevar
2017-11-15 08:27:38 +01:00
committed by GitHub
9 changed files with 369 additions and 72 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -403,6 +403,32 @@ describe('ol.rendering.style.Text', function() {
expectResemble(map, 'rendering/ol/style/expected/text-multipolygon.png', 4.4, done);
});
it('renders text background', function(done) {
createMap('canvas');
createFeatures();
var features = vectorSource.getFeatures();
features[0].getStyle().getText().setBackgroundFill(new ol.style.Fill({
color: 'red'
}));
features[1].getStyle().getText().setBackgroundFill(new ol.style.Fill({
color: 'red'
}));
features[1].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
color: 'blue',
width: 3
}));
features[2].getStyle().getText().setBackgroundFill(new ol.style.Fill({
color: 'red'
}));
features[2].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({
color: 'blue',
width: 3
}));
features[2].getStyle().getText().setPadding([5, 10, 15, 0]);
map.getView().fit(vectorSource.getExtent());
expectResemble(map, 'rendering/ol/style/expected/text-background.png', IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer without rotation', function(done) {
createMap('webgl');
createFeatures();