[Users] How to build a complex tree ?

Andreas Hocevar ahocevar at opengeo.org
Mon Jan 18 10:42:59 CET 2010


Hi,

see anwers inline.

Alessandro Pasotti wrote:
> I'm trying to build a complex tree from my kml layer list.
>
> The expected result is
>
>
> +  Tourist Resource layers (folder)
> [ ] Beni culturali (enable/disable all children when clicked)
>      [ ] Castelli
>      [ ] Musei
>
> ....
> [ ] Tracks
>     [ ] By foot
>     [ ] By bike
>         [ ] Mountain bike
>         [ ] Racing bike
>     [ ] By car
>         [ ] Normal car
>         [ ] Offroad 4X4
>     ........
>
> I have already generated a JSON tree like this:
>
>
> {
>      "leaf": false,
>      "name": "Beni culturali",
>      "kml": "/it/resource/poi/category/beni-culturali.kml",
>      "id": "poi.2",
>      "root": true,
>      "children": [
>       {
>        "leaf": true,
>        "name": "Castelli",
>        "kml": "/it/resource/poi/category/castelli.kml",
>        "id": "poi.2.4",
>        "root": false,
>        "children": [],
>        "icon": "/static/poi/icons/48.png"
>       },
>       {
>        "leaf": true,
>        "name": "Musei",
>        "kml": "/it/resource/poi/category/musei.kml",
>        "id": "poi.2.3",
>        "root": false,
>        "children": [],
>        "icon": "/static/poi/icons/55.png"
>       }
>      ],
>      "icon": "/static/poi/icons/49.png"
>     }
>    ],
>
>
> What is the beast approach, considering that I would like to use the
> "icon" field to generate a custom icon instead of the default one ?
> I'm trying with a  loader filter with no success.
>   

Setting the icon attribute of the node, as you have done in the snippet 
above, is sufficient to give you a custom icon. But your nodes are no 
layer nodes. Do you have a custom node type to process the kml attribute?

> Shall I build the tree node by node (by hand) or do you see a better solution ?
>   

Since you seem to have a 3-level structure, creating it node by node 
seems the best solution. With LayerLoader and LayerParamLoader, you only 
get 2 levels.


Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list