1 L.OSM.key = function (options) {
2 var control = L.control(options);
4 control.onAdd = function (map) {
5 var $container = $('<div>')
6 .attr('class', 'control-key');
9 .attr('class', 'control-button')
11 .attr('title', I18n.t('javascripts.key.tooltip'))
12 .html('<span class="icon key"></span>')
14 .appendTo($container);
17 .attr('class', 'key-ui');
20 .attr('class', 'sidebar_heading')
24 .text(I18n.t('javascripts.close'))
25 .attr('class', 'sidebar_close')
27 .bind('click', toggle))
30 .text(I18n.t('javascripts.key.title')));
32 var $section = $('<div>')
33 .attr('class', 'section')
36 options.sidebar.addPane($ui);
42 map.on('baselayerchange', updateButton);
47 map.on('zoomend baselayerchange', update);
48 $section.load('/key', update);
52 map.off('zoomend baselayerchange', update);
58 if (!button.hasClass('disabled')) {
59 options.sidebar.togglePane($ui, button);
63 function updateButton() {
64 var layer = map.getMapBaseLayerId();
65 button.toggleClass('disabled', layer !== 'mapnik');
69 var layer = map.getMapBaseLayerId(),
72 $('.mapkey-table-entry').each(function () {
73 var data = $(this).data();
74 if (layer == data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {