diff --git a/externs/olx.js b/externs/olx.js index c01ba3ab74..85c6d40c57 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6266,6 +6266,7 @@ olx.style.IconOptions.prototype.src; * snapToPixel: (boolean|undefined), * stroke: (ol.style.Stroke|undefined), * rotation: (number|undefined), + * rotateWithView: (boolean|undefined), * atlasManager: (ol.style.AtlasManager|undefined)}} * @api */ @@ -6353,6 +6354,14 @@ olx.style.RegularShapeOptions.prototype.stroke; olx.style.RegularShapeOptions.prototype.rotation; +/** + * Whether to rotate the shape with the view. Default is `false`. + * @type {boolean|undefined} + * @api + */ +olx.style.RegularShapeOptions.prototype.rotateWithView; + + /** * The atlas manager to use for this symbol. When using WebGL it is * recommended to use an atlas manager to avoid texture switching. diff --git a/src/ol/style/regularshapestyle.js b/src/ol/style/regularshapestyle.js index b8b1dd457a..b3766cd2c2 100644 --- a/src/ol/style/regularshapestyle.js +++ b/src/ol/style/regularshapestyle.js @@ -123,9 +123,15 @@ ol.style.RegularShape = function(options) { var snapToPixel = options.snapToPixel !== undefined ? options.snapToPixel : true; + /** + * @type {boolean} + */ + var rotateWithView = options.rotateWithView !== undefined ? + options.rotateWithView : false; + goog.base(this, { opacity: 1, - rotateWithView: false, + rotateWithView: rotateWithView, rotation: options.rotation !== undefined ? options.rotation : 0, scale: 1, snapToPixel: snapToPixel diff --git a/test/spec/ol/style/regularshapestyle.test.js b/test/spec/ol/style/regularshapestyle.test.js index 8df8e55e98..5c1a9a0029 100644 --- a/test/spec/ol/style/regularshapestyle.test.js +++ b/test/spec/ol/style/regularshapestyle.test.js @@ -4,6 +4,14 @@ describe('ol.style.RegularShape', function() { describe('#constructor', function() { + it('can use rotateWithView', function() { + var style = new ol.style.RegularShape({ + rotateWithView: true, + radius: 0 + }); + expect(style.getRotateWithView()).to.be(true); + }); + it('can use radius', function() { var style = new ol.style.RegularShape({ radius: 5,