[Users] How to share actions between multiple layers?

Adam Ratcliffe adam at prema.co.nz
Mon May 10 10:03:45 CEST 2010


I've taken the approach of creating an Ext.ButtonGroup that contains
my layer-specific actions which I add to the MapPanel toolbar. I store
a reference to this button group on the layer object.  When an item is
selected in the map legend (Ext.TreePanel) I remove the ButtonGroup
for the old layer (if it added one) and add the ButtonGroup for the
newly selected layer.  I found that I needed to pass autoDestroy =
false to the Ext.Toolbar.remove() function and hide the removed
ButtonGroup manually in order to be able to re-use the component when
its layer was re-selected.

Cheers
Adam

On Mon, May 10, 2010 at 4:14 PM, Eric Lemoine
<eric.lemoine at camptocamp.com> wrote:
> On Sunday, May 9, 2010, Adam Ratcliffe <adam at prema.co.nz> wrote:
>> Yes I'm using the DrawFeature and ModifyFeature controls.  Only 1 layer needs to be edited at a time so that's fine.
>>
>> What I'm unsure about is how to deal with the one-to-one relationship between a GeoExt.Action, an OpenLayers.Control and the layer referenced by the control.  I was thinking that I'd probably need to do something like create a set of action instances for each layer and when a layer is selected in the map legend remove the set of existing toolbar layer actions and add the actions for the selected layer.
>>
>> Does this sound like a reasonable approach or is there a better way?
>
> Either that or create a new set of actions each time a layer is selected.
>
> (Introducing a setControl method in GeoExt.Action may make sense.)
>
> Cheers,
>
> --
> 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.lemoine at camptocamp.com
> http://www.camptocamp.com
>


More information about the Users mailing list