/**
* @classdesc
* This control let you clean all the elements painted on the map.
* This control doesn't clean other markers or features added with other controls, like
* `cercalia.MapControls.Traffic`, `cercalia.MapControls.Meteo` ...
*
*
* @constructor
* @extends {ol.control.Control}
*/
cercalia.Control.Clean = function(){
/**
* @private
* @type {string}
*/
this.name_ = cercalia.MapControls.CleanControl;
/**
* Class name
* @private
* @type {string}
*/
this.CLASS_NAME_ = "cercalia.Control.Clean";
/**
* Button
* @private
* @type {HTMLElement}
*/
this.element_ = null;
this.element_ = document.createElement('div');
//this.element_.href = '#CercaliaControlCleanControl';
this.element_.className = "cercalia-big-icon cercalia-control cercalia-control-cleanControl";
cercalia.jQuery(this.element_).button({icons: {primary:"cercalia-big-icon cercalia-big-icon-rubber", secondary: "" }, text: false }).attr("title", cercalia.i18n._("TOOLTIP_CLEAN"));
cercalia.jQuery(this.element_).addClass("cercalia-tool-button");
var self = this;
this.element_.addEventListener('click', function(e) {
self.clean();
e.preventDefault();
}, false);
};
ol.inherits(cercalia.Control.Clean, ol.control.Control);
/**
* Executes the control action.
* Cleans the map overlays
*/
cercalia.Control.Clean.prototype.clean = function(){
cercalia.jQuery(".cercalia-tool-button.cercalia-tool-button-open").click().button("refresh");
var cercaliaMap = this.getMap().getCercalia();
cercaliaMap.removeAllOverlays();
cercaliaMap.clearCercaliaServices();
};
/**
* Create the button in the tools topbar
* @param {string} idTopBar Div element ID where the control will be embedded
*/
cercalia.Control.Clean.prototype.setTopBar = function (idTopBar) {
var self = this;
ol.control.Control.call(this, {
element: self.element_,
target: document.getElementById(idTopBar)
});
};