如何在一组中添加2个以上的图层? [英] how to add 2+ layers in a group?

查看:160
本文介绍了如何在一组中添加2个以上的图层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个组中添加两个或多个图层,以便我可以在layerswitcher分类中看到它们,并可以选择或取消全部!?

这是我的代码:

How can I add two or more layers in a group so that I can see them in layerswitcher categorised and can select or unselect all !?
Here is the code I have:

            var line_1 = new OpenLayers.Layer.Vector(" Line no - 1", {
                    visibility: true,
                    projection: dproj,
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    style: {strokeWidth: 4, strokeColor: "#ff0000", strokeOpacity: 1},
                    protocol: new OpenLayers.Protocol.HTTP({
                        url: "lines/en/line_1.kml",
                        format: new OpenLayers.Format.KML
                    })
            });

            var line_2 = new OpenLayers.Layer.Vector(" Line no - 2", {
                    visibility: true,
                    projection: dproj,
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    style: {strokeWidth: 4, strokeColor: "#008000", strokeOpacity: 1},
                    protocol: new OpenLayers.Protocol.HTTP({
                        url: "lines/en/line_2.kml",
                        format: new OpenLayers.Format.KML
                    })
            });
 var layers = [line_1, line_2]
 map.addLayers(layers);

现在我怎么能用名称Lines将这两个结合起来?

Now how can I gorup these two in 1 with the name "Lines" ?

推荐答案

我认为 GeoExt.tree 就是你想要的。



看到这封邮件:

I think GeoExt.tree is what you want.

See this mail :


OpenLayers的图层切换器不支持图层层次结构,
可能永远不会。我建议查看
MapFish(http://www.mapfish.org)的图层树。 MapFish图层树是基于OpenLayers中配置的图层自动配置的
或通过用户指定的模型配置的

OpenLayers' layer switcher does not support layer hierarchy and will probably never do. I'd recommend checking out the layer tree of MapFish (http://www.mapfish.org). MapFish layer tree is either auto-configured based on the layers configured in OpenLayers or configured through a user-specified model

http://www.osgeo.org/pipermail /openlayers-users/2008-June/006358.html

点击此处:
http://trac.osgeo.org/openlayers/browser/sandbox/jachym/ openlayers / examples / layer-groups.html?rev = 4958 它看起来像是支持它的openlayers的旧分支。

Check out here : http://trac.osgeo.org/openlayers/browser/sandbox/jachym/openlayers/examples/layer-groups.html?rev=4958 it looks like a old branch of openlayers that supports it.

让我们来看看:
http://api.geoext.org/1.0/examples/tree.html

我认为GeoExt.tree就是您想要的。

I think GeoExt.tree is what you want.

这篇关于如何在一组中添加2个以上的图层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆