style/Icon: Add setAnchor() method
This allows users to adjust the anchor after the `Icon` is defined. This can be useful if the anchor should depend on the rotation of the icon.
This commit is contained in:
@@ -172,6 +172,20 @@ describe('ol.style.Icon', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setAnchor', function() {
|
||||
it('resets the cached anchor', function() {
|
||||
const iconStyle = new Icon({
|
||||
src: 'test.png',
|
||||
size: size,
|
||||
anchor: [0.25, 0.25]
|
||||
});
|
||||
expect(iconStyle.getAnchor()).to.eql([9, 12]);
|
||||
|
||||
iconStyle.setAnchor([0.5, 0.5]);
|
||||
expect(iconStyle.getAnchor()).to.eql([18, 24]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getOrigin', function() {
|
||||
const offset = [16, 20];
|
||||
const imageSize = [144, 192];
|
||||
|
||||
Reference in New Issue
Block a user