[OpenLayers-Users] Change Layer Vis outside of LayerSwitcher

Stephen Woodbridge woodbri at swoodbridge.com
Mon Apr 27 11:11:13 EDT 2009


Christopher,

Round two :) Hopefully the link will work now in your browser, what are 
you using, btw. I do have it working in both IE 6.0 and Firefox 3.0.9 
and thought I would share the link again.

Everything(?) is working more or less. I need to work on the mapfile for 
the overlay streets as they are not very smooth, but I think that is a 
trade-off between anti-alias and transparent.

Your comments are always welcome and were right on as usual, which 
directed me right to the problem.

Thanks and best regards,
   -Steve

Christopher Schmidt wrote:
> On Sun, Apr 26, 2009 at 01:13:47PM -0400, Stephen Woodbridge wrote:
>> Christopher Schmidt wrote:
>>> On Sun, Apr 26, 2009 at 11:43:24AM -0400, Stephen Woodbridge wrote:
>>>> Hi,
>>>>
>>>> If I change the visibility of a layer in JavaScript, How do I get that 
>>>> reflected in LayerSwitcher? Or maybe the question should be: How do tell 
>>>> LayerSwitcher in JavaScript that I want to change layers selected?
>>> If you need to, something is broken. Can you share the code that isn't
>>> working?
>>>
>>> Regards,
>> Christopher,
>>
>> http://imaptools.com:8080/maps/dd3.html?lat=34.5315&lon=69.1571&zoom=14&layers=B00TFTTTF&start=69.150255%2034.535834&stop=69.158273%2034.52821&method=STS&lang=eng
>>
>> It is likely that my hack job of code has broken something.
>> Overlays seem to update ok, but the base layer is not updating.
>>
>> I am trying to add the buttons instead of the LayerSwitcher and finally 
>> got them to work, although there is probably a much easier way to do it.
>>
>> So to reproduce is click on the [Map][Satellite][Contour] or [Show 
>> labels] checkbox and these work as they should. If you open the 
>> layerswitcher, you will see that the "Overlay Streets" and "90M Contour 
>> Lines" toggle on and off with the button clicks, but changing the 
>> baselayer visibility with the [Map][Satellite] buttons does not update 
>> the layerswitcher.
> 
> When I open the above URL, it doesn't work in my browser, so I can't
> click anything to test it, but my guess is that you'r eusing
> setVisibility on the layer instead of setBaseLayer on th map to 'choose'
> a base layer. When changing base layers, you should always use
> setBaseLayer to pick the one you want to be the base.
> -- Chris
> 
>> I also have not looked into trying to make the buttons update when 
>> things are toggled in the layerswitcher. None of this is a real issue 
>> because layerswitcher will probably be commented out totally in the 
>> production system. But it seemed like a practical exercise to better 
>> understand how things work.
>>
>> I am always open to suggestions on better ways to code these solutions.
>>
>> Thank you,
>>   -Steve
> 




More information about the Users mailing list