简体   繁体   English

如何通过代码OpenLayers3扩展图层组

[英]How to expand layer group by code OpenLayers3

My question is simple: I need expand a layer group, just like the event clic in the "+" button but programmatically. 我的问题很简单:我需要扩展图层组,就像“ +”按钮中的事件clic一样,但是需要通过编程。

I have a group in this image 我在这张图片中有一个小组

组

I need expand the group like this 我需要像这样扩大小组

集团扩大

How can I do this programmatically in Openlayers3. 如何在Openlayers3中以编程方式执行此操作。 Ty for your help. 泰语为您提供帮助。

On Openlayers site, under examples section you have one fine example how can one implement similar behavior. 在Openlayers网站的“示例”部分下,您可以找到一个很好的示例,说明如何实现类似的行为。

http://openlayers.org/en/latest/examples/layer-group.html http://openlayers.org/en/latest/examples/layer-group.html

Also, something similar is explained here , but keep in mind that this example uses 3.4.0 version. 另外, 这里也说明了类似的内容,但请记住,此示例使用3.4.0版本。

You can do something like this for each group 您可以为每个小组做这样的事情

 var Group1 = new ol.layer.Group({ title: 'Group1', openInLayerSwitcher: false, visible: false, layers:[ new ol.layer.Group({ title: 'SubGroup1', openInLayerSwitcher: false, visible: false, layers: Object.values(G1) }), new ol.layer.Group({ title: 'SubGroup2', openInLayerSwitcher: false, visible: false, layers: Object.values(G2) })] }); G1['Layer1'] = new ol.layer.Tile({ title: "Layer1 in Group 1", baseLayer: false, visible: false, source: new ol.source.XYZ({ projection: 'EPSG:4326', wrapX: false, url: '/{z}/{x}/{-y}.png'//depends on the layer type }) }); 

And so on.. 等等..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM