Skip to content

Commit 87861d1

Browse files
committed
can now customize resetNorth for rotate control
1 parent fde23c1 commit 87861d1

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

externs/olx.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,7 @@ olx.control.ScaleLineOptions.prototype.units;
13151315
* tipLabel: (string|undefined),
13161316
* target: (Element|undefined),
13171317
* render: (function(ol.MapEvent)|undefined),
1318+
* resetNorth: (function()|undefined),
13181319
* autoHide: (boolean|undefined)}}
13191320
* @api stable
13201321
*/
@@ -1370,6 +1371,14 @@ olx.control.RotateOptions.prototype.autoHide;
13701371
*/
13711372
olx.control.RotateOptions.prototype.render;
13721373

1374+
/**
1375+
* Function called when the control is clicked. This will override the
1376+
* default resetNorth.
1377+
* @type {function()|undefined}
1378+
* @api
1379+
*/
1380+
olx.control.RotateOptions.prototype.resetNorth;
1381+
13731382

13741383
/**
13751384
* Target.

src/ol/control/rotatecontrol.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ ol.control.Rotate = function(opt_options) {
6363

6464
var render = options.render ? options.render : ol.control.Rotate.render;
6565

66+
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
67+
6668
goog.base(this, {
6769
element: element,
6870
render: render,
@@ -101,7 +103,11 @@ goog.inherits(ol.control.Rotate, ol.control.Control);
101103
*/
102104
ol.control.Rotate.prototype.handleClick_ = function(event) {
103105
event.preventDefault();
104-
this.resetNorth_();
106+
if (this.callResetNorth_ !== undefined) {
107+
this.callResetNorth_();
108+
} else {
109+
this.resetNorth_();
110+
}
105111
};
106112

107113

test/spec/ol/format/kmlformat.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ describe('ol.format.KML', function() {
16321632
expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_);
16331633
expect(style.getZIndex()).to.be(undefined);
16341634
});
1635-
1635+
16361636
it('can create text style for named point placemarks', function() {
16371637
var text =
16381638
'<kml xmlns="http://www.opengis.net/kml/2.2"' +
@@ -1644,7 +1644,8 @@ describe('ol.format.KML', function() {
16441644
' <IconStyle>' +
16451645
' <scale>0.3</scale>' +
16461646
' <Icon>' +
1647-
' <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>' +
1647+
' <href>http://maps.google.com/mapfiles/kml/pushpin/' +
1648+
'ylw-pushpin.png</href>' +
16481649
' </Icon>' +
16491650
' <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>' +
16501651
' </IconStyle>' +

0 commit comments

Comments
 (0)