# Source: bemap-model/bemap-layer.js

    /**
     * BeNomad BeMap JavaScript API - Layer class
     */

    /**
     * @classdesc
     * Base class for layer.
     * @public
     * @constructor
     * @param options.
     */
    bemap.Layer = function(options) {
      var opts = options || {};

      /**
       * @protected
       */
      this.native = null;

      /**
       * @protected
       */
      this.map = null;

      /**
       * @protected
       */
      this.visible = true;

      /**
       * @protected
       */
      this.name = opts.name ? opts.name : null;

      /**
       * @protected
       */
      this.base = opts.base ? opts.base : false;

      /**
       * @type {Boolean}
       * @protected
       */
      this.transparent = opts.transparent ? opts.transparent : false;

      /**
       * @protected
       */
      this.options = opts;
    };

    /**
     * @classdesc
     * Base class for OSM layer.
     * @public
     * @constructor
     * @param options.
     */
    bemap.OsmLayer = function(options) {
      this.url = options ? options.url : 'false';

      bemap.Layer.call(this, options);
    };
    bemap.inherits(bemap.OsmLayer, bemap.Layer);

    /**
     * @classdesc
     * Base class for WMS layer.
     * @public
     * @constructor
     * @param {Object} options See below the available values.
     * @param {String} options.layers Name of layers separated by comma.
     * @param {String} options.styles Name of styles separated by comma.
     */
    bemap.WmsLayer = function(options) {
      var opts = options || {};

      this.url = opts.url ? opts.url : 'false';
      this.layers = opts.layers ? opts.layers : 'default';
      this.styles = opts.styles ? opts.styles : '';
      this.format = opts.format ? opts.format : null;

      bemap.Layer.call(this, options);
    };
    bemap.inherits(bemap.WmsLayer, bemap.Layer);

    /**
     * @classdesc
     * Base class for BeMap layer.
     * @public
     * @constructor
     * @param {Object} options See below the available values.
     * @param {String} options.geoserver Name of BeMap Geoserver.
     * @param {String} options.layers Name of layers separated by comma.
     * @param {String} options.styles Name of styles separated by comma.
     */
    bemap.BemapLayer = function(options) {
      var opts = options || {};

      this.url = opts.url ? opts.url : 'false';
      this.geoserver = opts.geoserver ? opts.geoserver : undefined;
      this.layers = opts.layers ? opts.layers : 'default';
      this.styles = opts.styles ? opts.styles : '';
      this.format = opts.format ? opts.format : null;

      bemap.Layer.call(this, options);
    };
    bemap.inherits(bemap.BemapLayer, bemap.Layer);

    /**
     * @classdesc
     * Base class for Vector layer.
     * @public
     * @constructor
     * @param options.
     */
    bemap.VectorLayer = function(options) {
      bemap.Layer.call(this, options);
    };
    bemap.inherits(bemap.VectorLayer, bemap.Layer);

    /**
     *
     */
    bemap.ClusterLayer = function(options) {
      var opts = options || {};

      this.distance = opts.distance ? opts.distance : 40;
      this.style = opts.style ? opts.style : new bemap.clusterStyle();

      bemap.Layer.call(this, options);
    };
    bemap.inherits(bemap.ClusterLayer, bemap.Layer);

    /**
     * Remove the layer from the map.
     * @return {bemap.Layer} this.
     */
    bemap.Layer.prototype.remove = function() {
      if (this.map !== null && bemap.inheritsof(this.map, bemap.Map)) {
        this.map.removeLayer(this);
      }
      return this;
    };

    /**
     * Remove all object from the layer.
     * @return {bemap.Layer} this.
     */
    bemap.Layer.prototype.clear = function() {
      if (this.map !== null && this.native !== null) {
        this.map.clearLayer(this);
      }
      return this;
    };

    /**
     * Set the visibility of the layer.
     * @param {boolean} visible.
     * @return {bemap.Layer} this;
     */
    bemap.Layer.prototype.setVisible = function(visible) {
      if (this.map !== null && bemap.inheritsof(this.map, bemap.Map)) {
        this.map.visibleLayer(this, visible);
        this.visible = visible;
      }
      return this;
    };

    /**
     * Return the visibility of the layer.
     * @return {boolean} visible.
     */
    bemap.Layer.prototype.isVisible = function() {
      return this.visible;
    };

    /**
     *
      Set get feature info call back.
     * @param {object} options options.
     * @param {function} options.beforeCallback callback called at data reception and before display the popup.
     * @param {function} options.afterCallback callback called after display the popup.
     * @return {bemap.Listener} listener;
     */
    bemap.Layer.prototype.onGetFeatureInfo = function(options) {
      if (this.map !== null && bemap.inheritsof(this.map, bemap.Map)) {
        return this.map.onGetFeatureInfo(this, options);
      }
      return new bemap.Listener();
    };