[Cartoweb-dev] Set layer dynamic label

Alexandre Saunier alexandre.saunier at camptocamp.com
Thu Aug 18 12:34:48 EDT 2005


Hello,

zze-SIGALE PORTANERI F ext RD-BIZZ-SOP wrote:
> I am writing a new project and a specific plugin where I would like to 
> change the label of the layers dynamically, depending on the data I have 
> to display in the layer: By default these labels are handle by the 
> 'layers' coreplugin and the layers.tpl template.
> 
> - Is there a way to address these values from an other client plugin 
> ('label' field is a private data of the layer class and I didn't find an 
> API to access it) ? Or should I have to rewrite/extend the coreplugin 
> 'layers' in my project to implement this feature?

Perhaps you could try something like that:
- extend ClientLayers in your project and add some methods to 
dynamically update the layers labels. Make sure they are publicly 
accessible ("public" modifier)
- call those new layers methods from your "specific plugin" depending on 
what changes you want to make:
$this->getCartoclient()->getPluginManager()->getPlugin('yourCustomizedLayer')->yourCustomMethod(...)

You may also use the reverse approach:
- extend ClientLayers in your project
- override the standard methods behavior to make them call public 
methods in your "specific plugin" to figure out if current label must be 
updated.

Have a look in ClientLayers::fetchLayer() to know where labels are set 
on the client-side. Layers data (label, children,...) list is avaible 
using ClientLayers::getLayers().

> - In the sama way, is there a flag to avoid the display of an existing 
> layer dynamically  in the layers.tpl template? (hidden? frozen?)

"frozen" means that it is impossible for the end user to modify the 
layer selection status. I don't think it could help.

Prefer indeed dealing with the "hidden" layers attribute. Layers 
statuses (selected, hidden, frozen, unfolded,...) are avaible in 
ClientLayers::layersData property.

AS


More information about the Cartoweb-dev mailing list