[Users] GeoExt.grid.FeatureSelectionModel
Alexandre Dube
adube at mapgears.com
Wed Jan 6 14:18:26 CET 2010
Minika,
To have your panels not expanded on load, add collapsed: true to your
GridPanel definitions. To automatically show them on layer selection,
you could register a 'visibilitychanged' event on each layer and do a
myRelatedBoxObject.expand(); or something like that.
Hope it helps,
Alexandre
Minika Bjørge wrote:
>
> Hi,
>
> I have 4 KML layers on my map and I have followed the Feature
> selection model to create 4 grid panels that sync with each of the
> layers (see screenshot).
>
> *However, I would like the grid panel to be visible /_only when_/ the
> layer is selected i.e. the grid should be visible only for the active
> layer.* I don’t know how to do this. The way it is now, all the grid
> panel are expanded when the map loads. Is it possible to show the
> panel only when the layer is selected OR is it possible to expand the
> panel when the layer is selected (i.e. all the panels are collapsed by
> default)
>
> I have looked at the LegendPanel example but I am still not clear how
> to make this work with the feature info in the grid panels.
>
> Here’s a cut down version of my code and a screen shot(I have manually
> collapsed the grid panels):
>
> //Add the layers to map
>
> map.addLayer(layer2);
>
> map.addLayer(europa);
>
> map.addLayer(layer);
>
> map.addLayer(layer3);
>
> //KML layers
>
> map.addLayer(aarsmaks);
>
> map.addLayer(aarsmin);
>
> map.addLayer(kmlLayer);
>
> map.addLayer(middel);
>
> //Map controls
>
> map.addControl(new OpenLayers.Control.LayerSwitcher());
>
> map.addControl(new OpenLayers.Control.PanZoomBar());
>
> map.addControl(new OpenLayers.Control.MousePosition());
>
> selectControl = new OpenLayers.Control.SelectFeature(
>
> [kmlLayer, aarsmaks, aarsmin, middel],
>
> {
>
> clickout: true, toggle: false,
>
> multiple: false, hover: false,
>
> toggleKey: "ctrlKey", // ctrl key removes from selection
>
> multipleKey: "shiftKey" // shift key adds to selection
>
> }
>
> );
>
> map.addControl(selectControl);
>
> selectControl.activate();
>
> //Grid panel for KML layers
>
> store.load();
>
> store2.load();
>
> store3.load();
>
> store4.load();
>
> box= new Ext.grid.GridPanel({
>
> title: 'Vannstandsstasjoner',
>
> store: store,
>
> columns: [{heading: 'Sted', dataIndex: 'name'}],
>
> region: "west",
>
> width: 200,
>
> height: 170,
>
> border: false,
>
> collapsible: true,
>
> collapseMode: "mini",
>
> allowDrag: true,
>
> allowDrop: true,
>
> draggable: true,
>
> autoScroll: true,
>
> sm: new GeoExt.grid.FeatureSelectionModel()
>
> });
>
> box2= new Ext.grid.GridPanel({
>
> title: 'Årsmaksima',
>
> store: store2,
>
> columns: [{heading: 'Sted', dataIndex: 'name'}],
>
> region: "west",
>
> width: 200,
>
> height: 170,
>
> border: false,
>
> collapsible: true,
>
> collapseMode: "mini",
>
> allowDrag: true,
>
> allowDrop: true,
>
> draggable: true,
>
> autoScroll: true,
>
> sm: new GeoExt.grid.FeatureSelectionModel()
>
> });
>
> box3= new Ext.grid.GridPanel({
>
> title: 'Årsminima',
>
> store: store3,
>
> columns: [{heading: 'Sted', dataIndex: 'name'}],
>
> region: "west",
>
> width: 200,
>
> height: 170,
>
> border: false,
>
> collapsible: true,
>
> collapseMode: "mini",
>
> allowDrag: true,
>
> allowDrop: true,
>
> draggable: true,
>
> autoScroll: true,
>
> sm: new GeoExt.grid.FeatureSelectionModel()
>
> });
>
> box4= new Ext.grid.GridPanel({
>
> title: 'Årsmiddel',
>
> store: store4,
>
> columns: [{heading: 'Sted', dataIndex: 'name'}],
>
> region: "west",
>
> width: 200,
>
> height: 170,
>
> border: false,
>
> collapsible: true,
>
> collapseMode: "mini",
>
> allowDrag: true,
>
> allowDrop: true,
>
> draggable: true,
>
> autoScroll: true,
>
> sm: new GeoExt.grid.FeatureSelectionModel()
>
> });
>
> //Map layout - north, west and center regions
>
> var viewport = new Ext.Viewport({
>
> layout:'border',
>
> width:880,
>
> height:610,
>
> items:[
>
> {
>
> region: 'west', //contains the layer tree node and the feature grid
> for each layer
>
> id: 'west-panel',
>
> title: 'Tema',
>
> width: 200,
>
> minSize: 200-50,
>
> maxSize: 200+50,
>
> margins: '0 0 0 0',
>
> collapsible: true,
>
> collapseMode: 'mini',
>
> border: true,
>
> items: [tree,box,box2,box3,box4]
>
> },{
>
> region: 'center', //contains the map
>
> id: 'center-panel',
>
> title: 'Kart',
>
> margins: '0 0 0 5',
>
> collapsible: false,
>
> height:610,
>
> border:true,
>
> items: [mapPanel]
>
> }]
>
> });
>
> Many thanks for your help.
>
> Minika Bjørge
>
> Statens Kartverk Sjø
>
> minika.bjorge at statkart.no
>
> cid:image001.jpg at 01CA352F.AF8DEED0 <http://www.statkart.no/>
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list