Merge pull request #4362 from tamarmot/rotate_reset_north
Rotate control now takes optional resetNorth function.
This commit is contained in:
@@ -1315,6 +1315,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
|||||||
* tipLabel: (string|undefined),
|
* tipLabel: (string|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
* render: (function(ol.MapEvent)|undefined),
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
|
* resetNorth: (function()|undefined),
|
||||||
* autoHide: (boolean|undefined)}}
|
* autoHide: (boolean|undefined)}}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
@@ -1371,6 +1372,15 @@ olx.control.RotateOptions.prototype.autoHide;
|
|||||||
olx.control.RotateOptions.prototype.render;
|
olx.control.RotateOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control is clicked. This will override the
|
||||||
|
* default resetNorth.
|
||||||
|
* @type {function()|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.RotateOptions.prototype.resetNorth;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target.
|
* Target.
|
||||||
* @type {Element|undefined}
|
* @type {Element|undefined}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ ol.control.Rotate = function(opt_options) {
|
|||||||
|
|
||||||
var render = options.render ? options.render : ol.control.Rotate.render;
|
var render = options.render ? options.render : ol.control.Rotate.render;
|
||||||
|
|
||||||
|
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
render: render,
|
render: render,
|
||||||
@@ -101,7 +103,11 @@ goog.inherits(ol.control.Rotate, ol.control.Control);
|
|||||||
*/
|
*/
|
||||||
ol.control.Rotate.prototype.handleClick_ = function(event) {
|
ol.control.Rotate.prototype.handleClick_ = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.resetNorth_();
|
if (this.callResetNorth_ !== undefined) {
|
||||||
|
this.callResetNorth_();
|
||||||
|
} else {
|
||||||
|
this.resetNorth_();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user