2010年11月15日月曜日

GeoExt 04c Layer Tree - Visibility Grouping

OpenLayers で基本レイヤのない状態(allOverlays が true に設定されているとき)にLayerNode の checkedGroup を設定すると、該当レイヤは基本レイヤのようにレイヤノードはチェックボックスの替りにラジオボタンがレンダリングされ、同じ checkedGroup と設定されてたすべてのレイヤーは、同時に1つだけが表示されます。
geoext02_layer-tree.html を修正します。

---
Ext.onReady(function () {
map = new OpenLayers.Map('map', {
allOverlays: true, // 追加
projection: new OpenLayers.Projection("EPSG:2456"),
maxResolution: 'auto',
maxExtent: new OpenLayers.Bounds(-279000,1054000,-185000,1104000),
units: 'meters',
displayProjection: new OpenLayers.Projection("EPSG:4326")
});


layer1 = new OpenLayers.Layer.WMS( "Tokyo Height WMS",
"http://192.168.1.6/cgi-bin/mapserv?",
{
map: '/home/nob61/mapfile/tokyo_bmi_pgis_img2.map',
layers: 'height',
// isBaselayer: true, 削除
format: 'image/png'
});

---

var layerList = new GeoExt.tree.LayerContainer({
text: 'Tokyo Layers',
layerStore: mapPanel.layers,
leaf: false,
expanded: true,
loader: {
filter: function(record) {
return record.get("layer").name.indexOf("Tokyo") !== -1 // 修正
// OpenLayers.Layer.WMS の名前
},
// 追加
baseAttrs: {
checkedGroup: "tokyo"
}
// ここまで
}
});
---




Layer Nodes with Additional Radio Buttons 以下はうまく表示できませんでした。

0 件のコメント: