[OpenLayers-Users] LayerSwitcher - Panel show and disable layerentry - additional

Marc Jansen jansen at terrestris.de
Mon Aug 23 11:12:42 EDT 2010


Hi Jan,

I'd suggest continuing this thread in English, even though we both speek 
German.

The order of layers in the LayerSwitcher can be controlled using the 
configuration option "ascending". Just play around with that one:
http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Control/LayerSwitcher-js.html#OpenLayers.Control.LayerSwitcher.ascending

e.g.
new OpenLayers.Control.LayerSwitcher({
   ascending: false // or true
});

If you want layers to be invisible when being added to the map, use the 
config-option visibility:
http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.visibility

e.g.
new OpenLayers.Layer.WMS(
   'Name',
   'http://example.com',
   {
     layers: 'foo'
   },
   {
     visibility: false
   }
);

Hope that helps (this is untested code as always).

Regards,
Marc


On 21.08.2010 10:05, Jan Tappenbeck wrote:
> Am 20.08.2010 21:40, schrieb Marc Jansen:
>    
>> Hi Jan,
>>
>> looks as if you are still adding two LayerSwitcher Controls:
>>
>>     1. in the Map-Constructor (new OpenLayers.Map(...))
>>     2. and one in line 219 (map.addControl(new
>>        OpenLayers.Control.LayerSwitcher());)
>>
>> I'd suggest getting rid of the second one.
>>
>> What exactly do you mean by deactivate the checkbox? Adding
>> displayInLayerSwitcher : false to a layers options-object will result in
>> a layer not being shon in the LayerSwitcher.
>>
>> Regards,
>> Marc
>>
>>
>> Am 20.08.2010 16:37, schrieb Jan Tappenbeck:
>>      
>>> Am 20.08.2010 15:05, schrieb BMcBride:
>>>
>>>        
>>>> OK- So it looks like you have several instances of the LayerSwitcher control
>>>> in your code (see lines 46, 62, 219). This is why it does not appear to hide
>>>> correctly.  Remove 2 of these controls and you should be all set.
>>>>
>>>> As for your "layer not defined" error...  I was assuming that you were
>>>> trying to hide a layer when the map initially loads.  So if you wanted the
>>>> "Hofladen" layer to be initially hidden and unchecked, you would have to set
>>>> the layer as a variable and use setVisibility(false);.
>>>>
>>>>
>>>> var hofladen =  new OpenLayers.Layer.PopupMarker("Hofladen", {  ...
>>>>
>>>> map.addLayer(hofladen);
>>>> hofladen.setVisibility(false);
>>>>
>>>>
>>>> -----
>>>> Bryan R. McBride, GISP
>>>> http://www.bryanmcbride.com  bryanmcbride.com
>>>> http://geoserving.net/  geoserving.net
>>>>
>>>>          
>>> thanks for response.
>>>
>>> now i kill a double layers switch in
>>>
>>> http://www.tappenbeck.net/osm/maps/deu/index_new.php?id=1017
>>>
>>> but when you click "+" only an other layerpanel will show - like a
>>> overlay to the other. but i see no possiblity to hide the hole panel again !
>>>
>>> can you give me more detail because my englisch is not very well and i
>>> am a beginner of ol!!
>>>
>>> this was one question - the other is how to deactive a layer-checkbox in
>>> the panel by default ??!?!?
>>>
>>> can you help me more ??
>>>
>>> regards Jan :-)
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>>        
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>      
>
> Hi Marc !
>
> ich schreibe mal in Deutsch weiter - das ist für mich etwas einfacher
> und wir verstehen uns dann wohl besser.
>
> Zeile 219 habe ich deaktiviert - dann hat es auch geklappt. Kommt davon
> wenn man einfach Code C&P macht. Nur ist die Reihenfolge jetzt erst
> meine Karte und dann die Hintergrundlayer. Besser wäre natürlich, in
> Anlehnun der Standardausgabe die Reihenfolge zumzukehren. Geht das auch ??
>
> Die zweite Frage bezog sich auf die Layer - die sind normalerweise immer
> per Default aktiv. Ich möchte per Default einen oder mehrere bestimmte
> Layer deaktivieren - quasi per Code den Haken aus dem Layerpanel entfernen.
>
> Gruß aus Lübeck
> Jan :-)
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>    




More information about the Users mailing list