[Chameleon] JSTreeView

Edith TAKI edithaki at yahoo.ca
Mon May 30 08:48:13 EDT 2005


Hi Paul,
 
It works !!! 
 
I needed to create a metadata for each layer to retrieve group name 
and i changed the checkbox for the layer like this
id="layer-[metadata name=group]-[metadata name=layer_index]"
 
Thank you !!!

Paul Spencer <pspencer at dmsolutions.ca> wrote:
Edith,

I would tackle this by doing the following:

1. add metadata to each of your layers called layer_index and make it 
sequential 0 - nLayers

2. build your legend template file like this:

[leg_group_html]
 [input] )" name=[leg_group_name]>[leg_group_name]

[/leg_group_html]
[leg_layer_html]
 [input] name=layer_index]" type=checkbox value=[leg_layer_name] name=legendlayername[] 
onclick='toggleLayer( this )'>[leg_layer_name]

[/leg_layer_html]


3. add a couple of javascript functions to your template

function toggleGroup( obj )
{
var nLayers = 20; //set to number of layers in map file
for(i=0; i {
var layer_cb = document.getElementById( 'layer_'+obj.name+'_'+i );
if (layer_cb)
layer_cb.checked = obj.checked;
}
}

function toggleLayer( obj )
{
var group = (obj.id.split( "_" ))[1];
var group_cb = document.getElementById( group );
//case 1: unchecked layer, can uncheck the group
if (group_cb)
{
if (!obj.checked)
{
group_cb.checked = false;
return;
}
else // now have to check all the layers in this group
{
var nLayers = 20; //set to number of layers in map file
for(i=0; i {
layer_cb = document.getElementById( 'layer_'group+'_'+i );
if (cb && !cb.checked) //stop if any are unchecked
{
group_cb.checked = false;
return;
}
}
group_cb.checked = true; //all checked, can turn on group
}
}
}

Note this code is extremely rough and completely untested. Good Luck!!!

Cheers

Paul

Edith TAKI wrote:
> Hi,
> 
> Thank you Ferencik for your solution but you don"t need to 
> select/unselect layers in a group for your solution ...
> 
> My legend is generated dynamicaly with mapfile and legend_template and 
> look like that
> 
> 
> Group 1
> 
> * layer 1
> * layer 2
> * layer 3
> 
> Group 2
> 
> * layer1
> * layer2
> 
> 
> and i have a checkbox for each line ; those for layers are coded like that :
> 
>  [input] > value="[leg_layer_name]"
> [if name=layer_status oper=eq value=1]CHECKED[/if]
> [if name=layer_status oper=eq value=2]CHECKED[/if]>
> 
> 
> 
> what i need now is to code the group so that a click on a group could 
> check ou uncheck the layers depending.
> 
> For map refreshing, I used CWCJSAPI and i just solve the problem of 
> navigation buttons like zoomin zoomout, they no longer refresh all the page;
> Only Update button need now to reload the page but I have no idea for 
> Javascript so it'll be difficult !!
> 
> Thank you for your help
> 
> */Jano Ferencik /* wrote:
> 
> Hi Edith
> 
> the situation is like this..I created a javascript treemenu wich I
> am attaching
> to this email as a zip archive....you can modify and use it
> ....but....there are
> 2 things..
> 1 as long as The update Map widget refreshes the page You can do
> nothing about
> it... the menu will allways refresh and appear like on first
> load...you could
> solve this by creating some javascript handling some events...wich
> will keep the
> opened group open after refreshing....the script should use the :active
> pseudoclass of group(wich in this case must be links)...(this is
> only an advice
> )...I though one tome to do it but could take me a loomng time as my
> javascript
> skills are only basic
> 
> In my case I have another problem...I fave a huge number of layers
> in may
> Chameleon application(about 50) and I created a legend on multiple
> levels...it
> is refreshing i! tself on Update Map and second I think that the
> number of layers
> conducted to decreasing of speed when loading the map....
> A possibble solution could be the new Ka-Map project from DM
> solutions(ie. the
> map doesn't refresh itslelf on the basic actions like panning or
> zooming or
> layer controls).....but you will have to wait for the application
> Ka-map to be
> released....i think it will happen soon(ask Paul Spencer about this) :))
> 
> Regards
> 
> 
> > Hi list,
> >
> > I have a problem similar to jstreeview ; I developped
> legendTemplate to show
> at page load only groups so the user could developp a group by
> clicking its id
> to show the layers in the group ; I have two problems :
> > 1 - using Javascript to hide / show layers for each group.
> > I think Jano Ferencik (who first posted about Jstreeview) succeed
> doing
> > this ; could you help me ?
> > 2 - I have the same problem after Update, the page looks like on
> the fisrt
> > l! oading and user loose his environnment, only groups are visible.
> >
> > can somebody have any suggestions ?
> >
> > Thanks
> >
> >
> >
> >
> > ---------------------------------
> > Post your free ad now! Yahoo! Canada Personals
> >
> 
> 
> 
> 
> 
> ___________________________
> Cv-ul tau ia 500 euro/luna!
> http://500.myjob.ro
> 
> 
> ------------------------------------------------------------------------
> Post your free ad now! *Yahoo! Canada Personals* 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> 
> [leg_group_html]
> 
> 
> 
> 
> 
>  [input] > value="[leg_group_name]"
> [if name=layer_status oper=eq value=1]CHECKED[/if]
> [if name=layer_status oper=eq value=2]CHECKED[/if]
> onclick="checkAll();">
> 
> [leg_group_name] 
> 

> 
> 

> 
> [/leg_group_html]
> 
> [leg_layer_html order=ascending opt_flag=15]
> 
> 
> [if name=SHOWINLEGEND oper=isnull]
> 
>  [input] > value="[leg_layer_name]"
> [if name=layer_status oper=eq value=1]CHECKED[/if]
> [if name=layer_status oper=eq value=2]CHECKED[/if]>
> 
> 
> 
> 
> 
> 
> 
> 
> [if name=wms_title oper=isnull]
> [leg_layer_name] 
> [/if]
> 
> [if name=wms_title oper=isset]
> [metadata name=WMS_TITLE] 
> [/if]
> 
> 
> [/if]
> 
> [if name=SHOWINLEGEND oper=isset]
>  [input] 
> [/if]
> 

> [/leg_layer_html]
> 
>
> 
> function checkAll()
> {
> 
> }
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

-- 
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+




---------------------------------
Post your free ad now! Yahoo! Canada Personals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20050530/a9014fd1/attachment-0001.html


More information about the Chameleon mailing list