Merge pull request #12918 from mike-000/setDisplacement-2

Add setDisplacement method to ol/style/Image and subclasses
This commit is contained in:
Tim Schaub
2021-10-26 17:05:48 -06:00
committed by GitHub
8 changed files with 165 additions and 52 deletions

View File

@@ -198,6 +198,11 @@ describe('ol.style.Icon', function () {
size[0] / 2 - 20,
size[1] / 2 + 10,
]);
iconStyle.setDisplacement([10, 20]);
expect(iconStyle.getAnchor()).to.eql([
size[0] / 2 - 10,
size[1] / 2 + 20,
]);
});
});

View File

@@ -87,6 +87,7 @@ describe('ol.style.RegularShape', function () {
expect(style.getDisplacement()).to.an('array');
expect(style.getDisplacement()[0]).to.eql(0);
expect(style.getDisplacement()[1]).to.eql(0);
expect(style.getAnchor()).to.eql([5, 5]);
});
it('will use the larger radius to calculate the size', function () {
let style = new RegularShape({
@@ -109,6 +110,12 @@ describe('ol.style.RegularShape', function () {
expect(style.getDisplacement()).to.an('array');
expect(style.getDisplacement()[0]).to.eql(10);
expect(style.getDisplacement()[1]).to.eql(20);
expect(style.getAnchor()).to.eql([-5, 25]);
style.setDisplacement([20, 10]);
expect(style.getDisplacement()).to.an('array');
expect(style.getDisplacement()[0]).to.eql(20);
expect(style.getDisplacement()[1]).to.eql(10);
expect(style.getAnchor()).to.eql([-15, 15]);
});
});