/**
* Rotate NorthControl. Control for adjust map rotation fixed to North
* @class
* @constructor
* @param {Object} opt_options
* @extends {ol.control.Control}
*/
cercalia.Control.RotateNorth = function(opt_options) {
/**
* @private
* @type {string}
*/
this.name_ = "RotateNorth";
/**
* Class name
* @private
* @type {string}
*/
this.CLASS_NAME_ = "cercalia.Control.RotateNorth";
var options = opt_options || {};
/**
* @private
* @type {number}
*/
this.duration_ = options.duration ? options.duration : 250;
/**
* @private
* @type {number}
*/
this.top_ = options.top ? options.top : 0;
/**
* @private
* @type {string}
*/
this.element_ = null;
var className = null;
//Comprobamos que control de zoom se utiliza para poner un estilo equivalente a éste
if(options.controlZoomType && options.controlZoomType == cercalia.MapControls.Zoom ){
className = 'cercalia-control-rotate-north ol-unselectable';
} else {
className = 'cercalia-control-rotate-north-small ol-unselectable';
}
var anchor = document.createElement('a');
anchor.href = '#CercaliaControlRotateNorthControl';
anchor.innerHTML = 'N';
var self = this;
var handleRotateNorth = function(e) {
cercalia.jQuery(".cercalia-tool-button.cercalia-tool-button-open").click().button("refresh");
// prevent #rotate-north anchor from getting appended to the url
var view = self.getMap().getView();
self.getMap().beforeRender(ol.animation.rotate({
rotation: view.getRotation(),
duration: self.duration_,
easing: ol.easing.easeOut
}));
view.setRotation(0);
e.preventDefault();
};
anchor.addEventListener('click', handleRotateNorth, false);
anchor.addEventListener('touchstart', handleRotateNorth, false);
this.element_ = document.createElement('div');
this.element_.className = className;
this.element_.style.zIndex = "0";
this.element_.appendChild(anchor);
cercalia.jQuery(this.element_).css("top", this.top_ + "px");
cercalia.jQuery(anchor).button({ icons: { primary: "cercalia-icon cercalia-icon-north" }, text: false }).attr("title", cercalia.i18n._("TOOLTIP_NORHT"));
cercalia.jQuery(this.element_).addClass("cercalia-tool-button");
ol.control.Control.call(this, {
element: this.element_,
target: options.target
});
};
ol.inherits(cercalia.Control.RotateNorth, ol.control.Control);