+ }, this);
+
+ var label = $('<label></label>')
+ .text(layer.options.name)
+ .appendTo(item);
+
+ item.on('click', function() {
+ this.options.layers.forEach(function(other) {
+ if (other === layer) {
+ this._map.addLayer(other);
+ } else {
+ this._map.removeLayer(other);
+ }
+ }, this);
+ }.bind(this));
+
+ this._map.on('layeradd', function(e) {
+ if (e.layer === layer) {
+ item.addClass('active');
+ }
+ }).on('layerremove', function(e) {
+ if (e.layer === layer) {
+ item.removeClass('active');
+ }
+ });
+ }, this);