The LayerSwitcher automatically disables its layer elements when
zooming in/out following the min/max scale values of each layer. Is
that feature available with GeoExt tree nodes as well or do I need to do
that manually ?
Thanks,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
Users mailing list
Us...@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
this would be a useful improvement, but it is not yet implemented - patches welcome!
Regards,
Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
Thanks,
Alexandre
Matt Priour
Kestrel Computer Consutling
--------------------------------------------------
From: "Alexandre Dube" <ad...@mapgears.com>
Sent: Thursday, October 21, 2010 8:55 AM
To: "Andreas Hocevar" <ahoc...@opengeo.org>
Cc: "GeoEXT Users" <us...@geoext.org>
Subject: Re: [Users] Tree node disabling with min/max scale
Eric just told me to have a look at this thread.
Actually, he remembered something I wrote for a project 4 months ago.
So, here's how I managed to deal with min/maxScale in a layer tree.
This code is on application side and it probably doesn't deserves to
be in GeoExt.
var checkInRange = function(node) {
var n = node,
scale = map.getScale(),
minScale = n.attributes.minScale,
maxScale = n.attributes.maxScale;
if ((minScale && minScale > scale) || (maxScale && maxScale < scale)) {
n.getUI().addClass("gx-tree-layer-outofrange");
} else if (minScale || maxScale) {
n.getUI().removeClass("gx-tree-layer-outofrange");
}
};
map.events.on({
"zoomend": function() {
tree.getRootNode().cascade(checkInRange);
}
});
With the css styles :
.x-tree-node .gx-tree-layer-outofrange .x-tree-node-icon {
opacity: 0.5;
}
.gx-tree-layer-outofrange .x-tree-node-anchor span {
color: #777;
}
Pierre (so happy to contribute)
--
Pierre GIRAUD
Géomaticien, Analyste
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 93
Mail : pierre...@camptocamp.com
http://www.camptocamp.com
-Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Nah, it's no "race" but I definitively need that feature soon, so I
rather share how I would have done it.
Ideally, I would have made a new "rangechange" event for the
OpenLayers.Layer object and listen to that event to disable/enable the
UI of the node accordingly. Upon creation, a node would be disabled if
the 'inRange' is set to 'false' (unless it's a base layer).
That's pretty much it. Does that make sense ? How about your method ?
Alexandre
tree.on({
"expandnode": function(node) {
node.eachChild(checkInRange);
}
});
it walks the tree and for each gx_layer type node it checks if the
associated layer is in range.
If not then it disables the node and all of its children if any.
It also checks for any node that has all of its children disabled, and if so
it also disables that node.
I should have a working patch with test soon.
Matt Priour
--------------------------------------------------
From: "Alexandre Dube" <ad...@mapgears.com>
Sent: Thursday, October 21, 2010 9:52 AM
To: "Matt Priour" <mpr...@kestrelcomputer.com>
Cc: "Andreas Hocevar" <ahoc...@opengeo.org>; "GeoEXT Users"
Would it make sense to register a 'visibilitychanged' event inside
the LayerNode object and disable/enable the UI components accordingly ?
Having a plugin is nice but this seems like a feature everyone would
like to have by default. Having to configure an additional plugin for
that could be avoided IMHO.
Using the 'visibilitychanged' event registration method, you trigger
much less events and you don't need to check each node on each map
zoom. Only when a layer would be actually changed the according event
would trigger only once and for the layer only.
What do you think ? What do others think ?
Alexandre
If you wanted to strictly tie the node disable/enable to the layer's
'visibilitychanged' event then you would need to have some kind of flag that
would prevent the node from disabling itself after a checkbox change event
Matt Priour
--------------------------------------------------
From: "Alexandre Dube" <ad...@mapgears.com>
Sent: Thursday, October 21, 2010 10:51 AM
Alexandre
--------------------------------------------------
From: "Alexandre Dube" <ad...@mapgears.com>
Sent: Thursday, October 21, 2010 12:33 PM
Like I mentioned, I would need this feature rather quickly. Do you
wish to do the fix ? If not, I'm willing to make the changes (with the
appropriate ticket + patch).
Andreas, do you agree with the change or would you rather see it as a
plugin as Pierre and Matt proposed ?
Alexandre
On 10-10-21 01:58 PM, Matt Priour wrote:
> Good plan, I like that idea.
> Matt Priour
>
> --------------------------------------------------
> From: "Alexandre Dube" <ad...@mapgears.com>
> Sent: Thursday, October 21, 2010 12:33 PM
> To: "Matt Priour" <mpr...@kestrelcomputer.com>
> Cc: "Andreas Hocevar" <ahoc...@opengeo.org>; "GeoEXT Users"
> <us...@geoext.org>
> Subject: Re: [Users] Tree node disabling with min/max scale
>
>> The 'visibilitychanged' event would be used as usual, but for the
>> disabling/enabling we only need to check the 'inRange' property of
>> the layer. If it's set to false and it's not a base layer, disable
>> the node, else enable it. That way, it would prevent the issue you
>> mentioned.
>>
>> Alexandre
>>
--
A plugin would be great.
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.l...@camptocamp.com
http://www.camptocamp.com
I think the approach with the visibilitychanged event has less overhead. And if people prefer a plugin, it could also be combined with a plugin approach: whenever a layer node is added to the tree, the plugin could register the event.
But even if it's going to be default behavior, it can easily be disabled by making the css class for the disabled layer configurable.
Having said that, I don't have a strong opinion on plugin or not, but I do like the visibilitychanged approach better.
Regards,
Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Sorry about that but I forgot to mention that there's something
special with the code I proposed.
In my case, I had to deal with LayerParamNodes which are not tightly
bound to a layer but to a WMS sub-layer. I couldn't listen to
"visibilitychanged" because the OL Layer visibibility doesn't change
actually.
Code is better than talks so imagine the following tree (manual) configuration:
{
text: "Tourisme et vie local",
children: [{
text: "Tourisme",
children: [{
nodeType: "gx_layerparam",
text: "Piste de ski",
item: "pistes_ski",
maxScale: 50000
}, {
nodeType: "gx_layerparam",
text: "Piste de ski de fond",
item: "pistes_fond"
}]
}]
}
In this example, the maxScale value is set adequately to the
configuration in the mapfile. This is a bit specific because it is
configured manually, but we could imagine a way to get this
information by reading Capabilities.
So, the goal is probably not the same as the one Alexandre or Matt are
trying to reach.
Regards,
Pierre
--
Pierre GIRAUD
Géomaticien, Analyste
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 93
Mail : pierre...@camptocamp.com
In a way, the needs are the same. We all want to have nodes
reflecting to layers or paramlayers to disable when out of specific scales.
When dealing with LayerNodes, it's okay ( and I'd say recommended )
to use the OpenLayers.Layer 'inRange' property that is already
calculated from many properties such as minScale, maxScale,
minResolution, maxResolutions, resolutions, etc. It would be kinda
'duplicate' to define that information in the layertree nodes as well.
For the paramnodes, that's an other story. "param layers" are
specific to the OpenLayers.Layer.WMS layer object and there is no
"min/max scale/resolution" information per param layer in it. Unless
there a plans to integrate that kind of information in OpenLayers, I
think the best approach would be to use a plugin.
So in brief, for LayerNodes it could be dealt by default by the
"visibilitychanged" event and "inRange" layer property inside the class
itself and for ParamNodes we could use a plugin. How about it ?
Alexandre
--
Alexandre Dubé
Mapgears
www.mapgears.com
It appears that OL updates the inRange property for all layers (visible or
not) after the map's moveend event but before it actually does any
redrawing. I attach a map moveend listener for each LayerNode that could
reasonably be auto-disabled. I also evaluate the inRange property or result
of the calculateInRange function before the layer node is rendered.
[1] http://trac.geoext.org/attachment/ticket/235/autoDisableLayerNode.patch
Matt Priour
Kestrel Computer Consulting
--------------------------------------------------
From: "Alexandre Dube" <ad...@mapgears.com>
Sent: Friday, October 22, 2010 11:49 AM
To: <us...@geoext.org>
Subject: Re: [Users] Tree node disabling with min/max scale
> Hi Pierre,