1 //= require templates/map/layers
3 L.OSM.Layers = L.Control.extend({
4 onAdd: function (map) {
7 return this._container;
10 _initLayout: function (map) {
11 var className = 'leaflet-control-map-ui',
12 container = this._container = L.DomUtil.create('div', className);
14 var link = this._layersLink = L.DomUtil.create('a', 'leaflet-map-ui-layers', container);
16 link.title = 'Layers';
18 this._uiPane = this.options.uiPane;
20 $(link).on('click', $.proxy(this.toggleLayers, this));
23 toggleLayers: function (e) {
27 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
29 if ($(this._uiPane).is(':visible')) {
30 $(this._uiPane).hide();
31 controlContainer.css({paddingRight: '0'});
35 .html(JST["templates/map/layers"]());
37 var list = $(this._uiPane).find('.base-layers ul');
39 var layers = this.options.layers;
40 for (var i = 0; i < layers.length; i++) {
41 var item = $('<li></li>')
44 var div = $('<div></div>')
47 var map = L.map(div[0], {attributionControl: false, zoomControl: false})
48 .setView(this._map.getCenter(), Math.max(this._map.getZoom() - 2, 0))
49 .addLayer(new layers[i].layer.constructor);
51 map.dragging.disable();
52 map.touchZoom.disable();
53 map.doubleClickZoom.disable();
54 map.scrollWheelZoom.disable();
56 var label = $('<label></label>')
61 controlContainer.css({paddingRight: '200px'});
66 L.OSM.layers = function(options) {
67 return new L.OSM.Layers(options);