code: function(index) {
      var layers = [];
      for(var i = 0; i < this.layers.length; ++i) {
        var layer = this.layers[i];
        if(this._isLayerVisible(layer)) {
          layers.push(i);
        }
      }
      if (index >= layers.length) {
        return -1;
      }
      return +layers[index];
    }
docs: return the layer number by index taking into
  account the hidden layers.