Previous topic

TreePanel

Next topic

Unit tests

This Page

LegendWindowΒΆ

This example demonstrates how to display the legend to all layers present in the map in a popup.

Hide code
<script type="text/javascript">
  var api, map;

  function init() {
      map = new GeoAdmin.Map();

      var layers = [];

      layers.push(GeoAdmin.layers.buildLayerByName('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill'));
      layers.push(GeoAdmin.layers.buildLayerByName('ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill'));

      layers.push(GeoAdmin.layers.buildLayerByName('ch.bafu.schutzgebiete-ramsar'));
      layers.push(GeoAdmin.layers.buildLayerByName('ch.bafu.bundesinventare-vogelreservate'));
      layers.push(GeoAdmin.layers.buildLayerByName('ch.bafu.bundesinventare-moorlandschaften'));
      layers.push(GeoAdmin.layers.buildLayerByName('ch.bafu.bundesinventare-jagdbanngebiete'));

      map.addLayers(layers);

      var mapPanel = new GeoExt.MapPanel({
         tbar: [
         {
             text: 'Show legend',
             handler: function() {
               new GeoAdmin.LegendWindow({title: 'Legend', width: 600, height: 400, layerStore: mapPanel.store}).show();
             }
          }],
          width: 500,
          height: 340,
          map: map,
          renderTo: "mymap"
      });
  }
  </script>
     <body onload="init();">
  </script>
  <body onload="init();">
      <div id="mymap" style="float: right; width:400px;height:340px;border:1px solid grey;padding: 0 0 0 0;margin:10px !important;"></div>
      <script type="text/javascript" src="../../../loader.js"></script>
  </body>