[Users] GeoExt2 Sublayer Example?
Francesco D'Alesio
francesco.dalesio at r3-gis.com
Wed Feb 20 13:17:41 CET 2013
Hello Dave,
I'm sorry, I misunderstood your initial question.
I'm dealing with a layers container, so I built a plugin for a
layergroup node that holds OpenLayers.Layer instances.
I'm not using the "layers" param of OpenLayers.Layer as in
LayerParamLoader
However, here's the code
/**
* The LayerFolder plugin. This is used to create a node that holds
multiple layers, keeping checkboxes syncd
* {plugins: ['gx_layerfolder'], ...}
*
*/
Ext.define('GeoExt.tree.LayerFolderNode', {
extend: 'Ext.AbstractPlugin',
alias: 'plugin.gx_layerfolder',
init: function(target) {
var me = this,
checked = true,
layer;
target.eachChild(function(node) {
layer = node.get('layer');
if(!layer.getVisibility()) checked = false;
layer.events.on({
'visibilitychanged' : me.onChildLayerVisibilityChanged,
scope: me
});
});
target.set('checked', checked);
target.on('afteredit', function(node, modifiedFields) {
if(~Ext.Array.indexOf(modifiedFields, 'checked')) {
me.onCheckChange();
}
});
me.target = target;
},
/**
* @private
* Updates the visibility of the child layers
* node.
*/
onCheckChange: function() {
var node = this.target,
checked = this.target.get('checked');
if(!node._visibilityChanging) return;
node._visibilityChanging = true;
node.eachChild(function(node) {
node.get('layer').setVisibility(checked);
});
delete node._visibilityChanging;
},
/**
* @private
* Updates the visibility this node, when children visibility changes
*
*/
onChildLayerVisibilityChanged: function() {
var node = this.target;
if(!node._visibilityChanging) return;
var checked = true;
node.eachChild(function(childNode) {
if(!childNode.get('layer').getVisibility()) checked = false;
});
node._visibilityChanging = true;
node.set('checked', checked);
delete node._visibilityChanging;
}
});
Francesco
-------Dave Kliphon wrote--------
Subject: RE: [Users] GeoExt2 Sublayer Example?
Date: 19.02.2013 21:39
>
> Francesco,
>
> It seems that we would need to develop both layer node group and group
> loader classes, similar to the LayerParamNode and LayerParamLoader
> scripts in v1.1. Pass along any code examples if you have them,
> otherwise we will follow your lead in developing this custom sub-layer
> capability.
>
> Do you or does anyone know if the sub-layer feature will ultimately be
> revived in GeoExt2, and is there a GeoExt2 release date?
>
> Thanks for your help,
>
> Dave
>
> FROM: Francesco D'Alesio [mailto:francesco.dalesio at r3-gis.com]
> SENT: Tuesday, February 19, 2013 2:00 AM
> TO: Dave Kliphon
> CC: users at geoext.org
> SUBJECT: Re: [Users] GeoExt2 Sublayer Example?
>
> Hello Dave,
> I've defined a layegroup plugin, similar to GeoExt.tree.LayerNode ,
> that simply get \"checked\" from children and pass the \"check change\"
> event to children.
>
> Francesco
>
> Il 18/02/2013 22:59, Dave Kliphon ha scritto:
> >
> > Does anyone have an example of sublayer creation in GeoExt2? It
> > appears that examples/tree/tree.js is incomplete in this respect (the
> > Tasmanian Group Layer is a single tier, unlike in 1.1).
> >
> > If there are no examples, is there a timeframe for release, or advice
> > on developing a temporary solution?
> >
> > Thanks!
> >
> > Dave
> >
> >
> > _______________________________________________
> >
> >
> > Users mailing list
> >
> >
> > <a href=\\\"mailto:Users at geoext.org\\\">Users at geoext.org</a>
> >
> >
> > <a
> > href=\\\"http://www.geoext.org/cgi-bin/mailman/listinfo/users\\\">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a>
> >
>
> --
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20130220/f96ec61f/attachment-0001.htm
More information about the Users
mailing list