- L.DomEvent
- .on(this._uiPane, 'click', L.DomEvent.stopPropagation)
- .on(this._uiPane, 'click', L.DomEvent.preventDefault)
- .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
+ var baseSection = $('<section>')
+ .addClass('base-layers')
+ .appendTo(this.$ui);
+
+ $('<p>')
+ .text(I18n.t('javascripts.map.layers.base'))
+ .appendTo(baseSection);
+
+ list = $('<ul>')
+ .appendTo(baseSection);
+
+ layers.forEach(function(layer) {
+ var item = $('<li>')
+ .appendTo(list);
+
+ if (map.hasLayer(layer)) {
+ item.addClass('active');
+ }
+
+ var div = $('<div>')
+ .appendTo(item);
+
+ map.whenReady(function() {
+ var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false})
+ .setView(map.getCenter(), Math.max(map.getZoom() - 2, 0))
+ .addLayer(new layer.constructor);
+
+ miniMap.dragging.disable();
+ miniMap.touchZoom.disable();
+ miniMap.doubleClickZoom.disable();
+ miniMap.scrollWheelZoom.disable();
+
+ map.on('moveend', function() {
+ miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0));
+ });
+
+ div.data('map', miniMap);
+ });
+
+ var label = $('<label>')
+ .text(layer.options.name)
+ .appendTo(item);
+
+ item.on('click', function() {
+ layers.forEach(function(other) {
+ if (other === layer) {
+ map.addLayer(other);
+ } else {
+ map.removeLayer(other);
+ }
+ });
+ });
+
+ map.on('layeradd layerremove', function() {
+ item.toggleClass('active', map.hasLayer(layer));
+ });
+ });