admin管理员组文章数量:1327308
I'd like to be able to tell what ol.layer.Group(s) a layer is part of during a user interaction, without going through all the groups on the map top-down.
Is there a way to do this? I'm currently using ol3 v3.10.2.
I'd like to be able to tell what ol.layer.Group(s) a layer is part of during a user interaction, without going through all the groups on the map top-down.
Is there a way to do this? I'm currently using ol3 v3.10.2.
Share Improve this question asked Oct 21, 2015 at 18:04 ryansstackryansstack 1,4761 gold badge18 silver badges33 bronze badges2 Answers
Reset to default 6During initialising of your layers asign an attribute, on each layer, to verify the group this layer belongs to. like so:
var vector = new ol.layer.Vector({
GROUP : 'group1',
source: vectorSource,
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({color: '#FFFFFF'}),
stroke: new ol.style.Stroke({
color: '#000000',
width: 3
})
})
})
});
and then you may get the group like so:
layer.get('GROUP');
Looking at the ol.layer.Group, ol.collection and goog.array, none of these set an backwards reference to the layer. So you'll have to dig down trough all the groups, as far as I can see.
本文标签: javascriptHow to find layer group from layer in Openlayers 3Stack Overflow
版权声明:本文标题:javascript - How to find layer group from layer in Openlayers 3? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742203420a2432376.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论