[OpenLayers-Users] LayerSwitcher order

karpi karpi.lists at email.cz
Sun Jul 16 06:32:35 CDT 2006


14/07/06 15:32, euzuro at gmail.com napsal(a):
> On 7/14/06, karpi <karpi.lists at email.cz> wrote:
> >Hello.. Im experimenting with openlayers, on this site:
> >http://gismaster.liberix.cz/openlayers/
> >Please, there is my beginners questions:
> >
> >1) Can i change seting order of layers in 
> >OpenLayers.Control.LayerSwitcher() ??
> > ( I would like to have latest drawn layer on top, first drawn at the
> >bottom..)
> 
> currently openlayers does not support drawing of layers in reverse order, 
> but
> if you would like to do so, it would be very easy. you just need to
> reverse the loop
> in the redraw function in  lib/OpenLayer/Control/LayerSwitcher.js:
> 
> 
>   /**
>    * @returns A reference to the DIV DOMElement containing the switcher tabs
>    * @type DOMElement
>    */
>    redraw: function() {
> 
>        //clear out previous incarnation of LayerSwitcher tabs
>        this.div.innerHTML = "";
>        var visible = false;
>        for( var i = 0; i < this.map.layers.length; i++) {
>            if (visible && this.mode == "radio") {
>                this.map.layers[i].setVisibility(false);
>            } else {
>                visible = this.map.layers[i].getVisibility();
>            }
>            this.addTab(this.map.layers[i]);
>        }
> 
>        return this.div;
>    },
> 

Uff, thanx a much.. Im really not java coder. This was my first line :)
only one layer changed. But it works:

    redraw: function() {

        //clear out previous incarnation of LayerSwitcher tabs
        this.div.innerHTML = "";
        var visible = false;
        for( var i = 0; i < this.map.layers.length; i++) {
            if (visible && this.mode == "radio") {
                this.map.layers[i].setVisibility(false);
            } else {
                visible = this.map.layers[i].getVisibility();
            }
            var irev = this.map.layers.length -1 -i ;
            this.addTab(this.map.layers[irev]);
        }
            
        return this.div;
    },


> 
> >2) How can i avoid  "freted shape" of blue layer switchers ?
> 
> This is due to specifications in your stylesheet...
> 
> if you comment out the margin styles from "p", they are fixed.
> 
>  p {text-indent: 30px;
> /*  border-style: dashed;
>    border-width: 1px; */
>    text-align: justify;
> /*    margin-left: 10%;
>    margin-right: 10%; */
>    margin-top: 30px;
>    margin-bottom: 60px;
>    text-indent: 20px;
>    }

That was it.. thanks..


> 
> >3) I do not know.. there is probably out of openlayers control, but can
> >i display "basic" layer from http://labs.metacarta.com/wms/vmap0 not
> >fully opaque, but only semitransparent ?
> 
> Hmm... not sure if this is possible.... schuyler? chris?
> 
> Anyways hope #1 & 2 help you out a bit,
> 
> -erik
















-- 
karpi from
http://gismaster.liberix.cz




More information about the Users mailing list