[Users] Legend in Accordion panel

Luís de Sousa luis.a.de.sousa at gmail.com
Wed May 22 10:06:11 CEST 2013


Dear all,

I've tried to add the LegendPanel object to the main panel in several ways
but it never works (appears simply blank). The only way the LegendPanel is
correctly associated with the map is by defining it in line in the items
array of the main panel (that must contain a MapPanel) and without
specifying a LayerStore. Please see below two configuration examples
showing who it works and how it doesn't.

My first question: is this the way it is supposed to be or am I missing
something in the LegendPanel configuration?

And secondly: is there any other way to show a legend with GeoExt?

Thank you,

Luís

/****************************************************************************
 * Config 1: Legend defined in line without layerStore - it works

var mapPanel = new GeoExt.MapPanel({
        region: "center",
        collapsible: false,
        floatable: false,
        xtype: "gx_mappanel",
        map: map
    });

var LayerNodeUI = Ext.extend(
    GeoExt.tree.LayerNodeUI,
    new GeoExt.tree.TreeNodeUIEventMixin()
);

   var treeConfig = [{
        nodeType: "gx_baselayercontainer",
        expanded: true
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true
    }];

    var treePanel = new Ext.tree.TreePanel({
    itemId:'navTree',
        region: "east",
        title: "Layers",
        width: 170,
        collapsible: true,
        autoScroll: true,
        enableDD: true,
        plugins: [{
            ptype: "gx_treenodecomponent"
        }],
        loader: {
            applyLoader: false,
            uiProviders: {"custom_ui": LayerNodeUI}
        },
        root: {children: treeConfig},
        rootVisible: false,
        lines: false
    });

    var mainPanel = new Ext.Panel({
    layout:'border',
    bodyBorder: false,
    renderTo: "MiniMap",
        stateId: "MiniMap",
        height: 400,
        width: 700,
defaults: {
    split: true,
            autoHide: false,
            useSplitTips: true,
},
items: [mapPanel, treePanel,
{
title: "Legend",
xtype: "gx_legendpanel",
region:'west',
width: 100,
collapsible: true,
autoScroll: true,
enableDD: true,
padding: 5,
rootVisible: false,
lines: false
}]
   });
/****************************************************************************/

/****************************************************************************
 * Config 2: Legend defined as a variable with layerStore - doesn't work

var mapPanel = new GeoExt.MapPanel({
        region: "center",
        collapsible: false,
        floatable: false,
        xtype: "gx_mappanel",
        map: map
    });

var myLayerStore = new GeoExt.data.LayerStore({
    map: map,
    layers: map.layers
    });

  var legendPanel = new Ext.Panel({
title: "Legend",
xtype: "gx_legendpanel",
layerStore: myLayerStore,
region:'west',
width: 100,
collapsible: true,
autoScroll: true,
enableDD: true,
padding: 5,
rootVisible: false,
lines: false
});

var LayerNodeUI = Ext.extend(
    GeoExt.tree.LayerNodeUI,
    new GeoExt.tree.TreeNodeUIEventMixin()
);

   var treeConfig = [{
        nodeType: "gx_baselayercontainer",
        expanded: true
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true
    }];

    var treePanel = new Ext.tree.TreePanel({
    itemId:'navTree',
        region: "east",
        title: "Layers",
        width: 170,
        collapsible: true,
        autoScroll: true,
        enableDD: true,
        plugins: [{
            ptype: "gx_treenodecomponent"
        }],
        loader: {
            applyLoader: false,
            uiProviders: {"custom_ui": LayerNodeUI}
        },
        root: {children: treeConfig},
        rootVisible: false,
        lines: false
    });

    var mainPanel = new Ext.Panel({
    layout:'border',
    bodyBorder: false,
    renderTo: "MiniMap",
        stateId: "MiniMap",
        height: 400,
        width: 700,
defaults: {
    split: true,
            autoHide: false,
            useSplitTips: true,
},
items: [mapPanel, treePanel, legendPanel]
   });
/****************************************************************************/


On 21 May 2013 11:52, Luís de Sousa <luis.a.de.sousa at gmail.com> wrote:

> Hello everyone,
>
> I'm trying to integrate a Legend panel into an accordion, with the
> following set up:
>
>   myLayerStore = new GeoExt.data.LayerStore({
>     map: myMap,
>     layers: myMap.layers
>   });
>
>   myLegend = new Ext.Panel({
>  title: "Legend",
> xtype: "gx_legendpanel",
> layerStore: myLayerStore,
>  collapsible: true,
> autoScroll: true,
> enableDD: true,
>  padding: 5,
> rootVisible: false,
> lines: false
>   });
>
> And then myLegend is included in the items array of the Accordion panel.
>
> This way the Legend panel doesn't work, it doesn't send any requests to
> the server and remains blank. What is wrong in this set up?
>
> Thank you,
>
> Luís
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20130522/57a5bf76/attachment.htm 


More information about the Users mailing list