L.OSM.Layers = L.Control.extend({
onAdd: function (map) {
+ this._map = map;
this._initLayout(map);
return this._container;
},
link.href = '#';
link.title = 'Layers';
- this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
-
- L.DomEvent
- .on(this._uiPane, 'click', L.DomEvent.stopPropagation)
- .on(this._uiPane, 'click', L.DomEvent.preventDefault)
- .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
+ this._uiPane = this.options.uiPane;
$(link).on('click', $.proxy(this.toggleLayers, this));
},
} else {
$(this._uiPane)
.show()
- .html(JST["templates/map/layers"]({layers: this.options.layers}));
+ .html(JST["templates/map/layers"]());
+
+ var list = $(this._uiPane).find('.base-layers ul');
+
+ var layers = this.options.layers;
+ for (var i = 0; i < layers.length; i++) {
+ var item = $('<li></li>')
+ .appendTo(list);
+
+ var div = $('<div></div>')
+ .appendTo(item);
+
+ var map = L.map(div[0], {attributionControl: false, zoomControl: false})
+ .setView(this._map.getCenter(), Math.max(this._map.getZoom() - 2, 0))
+ .addLayer(new layers[i].layer.constructor);
+
+ map.dragging.disable();
+ map.touchZoom.disable();
+ map.doubleClickZoom.disable();
+ map.scrollWheelZoom.disable();
+
+ var label = $('<label></label>')
+ .text(layers[i].name)
+ .appendTo(item);
+ }
+
controlContainer.css({paddingRight: '200px'});
}
}
link.href = '#';
link.title = this.options.title;
- this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
-
- L.DomEvent
- .on(this._uiPane, 'click', L.DomEvent.stopPropagation)
- .on(this._uiPane, 'click', L.DomEvent.preventDefault)
- .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
+ this._uiPane = this.options.uiPane;
var h2 = L.DomUtil.create('h2', '', this._uiPane);
h2.innerHTML = I18n.t('javascripts.share.title');
margin: 10px;
}
-.leaflet-map-ui-layers {
- box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
- background: #f8f8f9;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- background-position: 50% 50%;
- background-repeat: no-repeat;
- display: block;
- width: 36px;
- height: 36px;
-}
+#map-ui {
+ position: absolute;
+ display: none;
+ right: 0;
+ width: 200px;
+ height: 100%;
+ background: white;
-.leaflet-control-layers-separator {
- margin: 5px -10px !important;
+ .leaflet-container {
+ width: 100%;
+ height: 50px;
+ }
}
.leaflet-control-attribution {