1 $(document).ready(function () {
 
   2   $("#open_map_key").click(function (e) {
 
   5     var url = $(this).attr('href'),
 
   6         title = $(this).text();
 
   8     function updateMapKey() {
 
   9       var mapLayer = getMapBaseLayer().keyid,
 
  10           mapZoom = map.getZoom();
 
  12       $(".mapkey-table-entry").each(function () {
 
  13         var data = $(this).data();
 
  15         if (mapLayer == data.layer &&
 
  16             mapZoom >= data.zoomMin && mapZoom <= data.zoomMax) {
 
  24     $("#sidebar_content").load(url, updateMapKey);
 
  26     openSidebar({ title: title });
 
  28     $("#sidebar").one("closed", function () {
 
  29       map.off("zoomend baselayerchange", updateMapKey);
 
  32     map.on("zoomend baselayerchange", updateMapKey);