<br><font size=2 face="sans-serif">This code works if comment "
layers.length == 1"</font>
<br><font size=2 face="sans-serif">var addLayersToMap = function()</font>
<br><font size=2 face="sans-serif">{ </font>
<br><font size=2 face="sans-serif">var ov_overlays;</font>
<br><font size=2 face="sans-serif">for( i in overlays )</font>
<br><font size=2 face="sans-serif">{ map.addLayer(
overlays[i] );</font>
<br><font size=2 face="sans-serif"> ov_overlays
= overlays[i].clone();</font>
<br><font size=2 face="sans-serif"> ov_map.addLayer(
ov_overlays );</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> overlays[i].events.register('visibilitychanged',
overlays[i], function()</font>
<br><font size=2 face="sans-serif">
{ </font>
<br><font size=2 face="sans-serif">
var layers
= ov_map.getLayersByName(this.name); // this is the layer </font>
<br><font size=2 face="sans-serif">
if(layers
/*&& layers.length == 1*/)</font>
<br><font size=2 face="sans-serif">
layers[0].setVisibility(this.getVisibility())</font>
<br>
<br><font size=2 face="sans-serif">
});</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<br><font size=2 face="sans-serif">layers.length is always = 2</font>
<br><font size=2 face="sans-serif">Why ov_map.getLayersByName(this.name)
returns 2 layers?</font>
<br>
<br><font size=2 face="sans-serif">Alexandre, i don't understand want you
mean by</font>
<br><font size=2 face="sans-serif">"</font><tt><font size=2>and attach
it to the original layer ( layer.clonedLayer = myCloneLayer )</font></tt><font size=2 face="sans-serif">"</font>
<br><font size=2 face="sans-serif">Do you think that could help with the
length returned by ov_map.getLayersByName(this.name)</font>
<br>
<p><font size=3>thanks </font>
<p><font size=3>Steve</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Alexandre Dube <adube@mapgears.com>@openlayers.org</b>
</font>
<br><font size=1 face="sans-serif">Envoyé par : users-bounces@openlayers.org</font>
<p><font size=1 face="sans-serif">05/02/2010 09:43 AM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">A</font></div>
<td><font size=1 face="sans-serif">Steve.Toutant@inspq.qc.ca</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">users@openlayers.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Objet</font></div>
<td><font size=1 face="sans-serif">Re: [OpenLayers-Users] Magnifier window</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br>
<br>
<br><tt><font size=2>Steve,<br>
<br>
You could try (pseudo-code):<br>
<br>
For each layer<br>
Clone it, add it to ov-map and attach it to the original layer
( layer.clonedLayer = myCloneLayer )<br>
Register a visibilitychange event to a onVisibilityChanged function<br>
<br>
onVisibilityChanged: function(event)<br>
this.clonedLayer.setVisibility(this.visibility())<br>
<br>
Regards,<br>
<br>
Alexandre<br>
<br>
<br>
Alexandre Dube wrote:<br>
> Steve,<br>
><br>
> Instead of relying on the layer's position in the layers array,
try to <br>
> use the following the getLayersByName method (see in my first reply).
<br>
> Tell me if that worked.<br>
><br>
> Alexandre<br>
><br>
><br>
> Steve.Toutant@inspq.qc.ca wrote:<br>
> <br>
>> Almost done....Amasing how things are easy to do with OL.<br>
>><br>
>> I have a wms layers array, "overlays[]"<br>
>> I use this code to create the layers array of the overview map
and to <br>
>> define the visibilitychanged event.<br>
>> var addLayersToMap = function()<br>
>> { <br>
>> for( i in overlays )//overlays contains my wms layers<br>
>> {<br>
>> map.addLayer( overlays[i] );<br>
>> ov_overlays[i] = overlays[i].clone();<br>
>> ov_map.addLayer( ov_overlays[i] );<br>
>><br>
>> //Ajoute un listener au niveau de
la carte principal pour <br>
>> gérer l'affichage sur la ov_map<br>
>> overlays[i].events.on(<br>
>> {<br>
>> 'visibilitychanged':
function(event)<br>
>> {<br>
>>
<br>
>> ov_overlays[i].setVisibility(overlays[i].getVisibility());<br>
>> }<br>
>> });<br>
>> }<br>
>> }<br>
>><br>
>> in run time, only the visibility of the last layer of the array
gets <br>
>> updated in the other map.<br>
>> I also tried with map.addLayers after adding the overlays[i].
events <br>
>> on...with the same result<br>
>><br>
>> Do you see something wrong<br>
>> thanks<br>
>> Steve<br>
>><br>
>><br>
>><br>
>><br>
>> *Alexandre Dube <adube@mapgears.com>*<br>
>><br>
>> 04/02/2010 03:36 PM<br>
>><br>
>>
<br>
>> A<br>
>>
Steve.Toutant@inspq.qc.ca<br>
>> cc<br>
>>
users@openlayers.org<br>
>> Objet<br>
>>
Re: [OpenLayers-Users] Magnifier window<br>
>><br>
>><br>
>><br>
>>
<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Hi Steve,<br>
>><br>
>> I think you could do something like that (pseudo-code) :<br>
>><br>
>> Create your original map<br>
>> Create all your layers and add them to the map<br>
>><br>
>> Create your ov-map<br>
>> Register a mapmove event to the map to make ov-map follow
it<br>
>> For each layer<br>
>> Clone it and add it to ov-map<br>
>> Register a visibilitychange event to a onVisibilityChanged
function<br>
>><br>
>> onVisibilityChanged: function(event)<br>
>> var layers = ov-map.getLayersByName(this.name); //
this is the layer<br>
>> the visibility was changed<br>
>> if(layers && layers.length == 1)<br>
>> layers[0].setVisibility(this.visibility())<br>
>><br>
>> Do you get the idea ?<br>
>><br>
>> Best regards,<br>
>><br>
>> Alexandre<br>
>><br>
>> Steve.Toutant@inspq.qc.ca wrote:<br>
>> <br>
>>> Hi,<br>
>>> I'm using openlayers with geoext.<br>
>>> I would like to create a magnifier window. So it is like an
overview<br>
>>> map with a fix map center and a fix zoom level, but the main
map and<br>
>>> this overview map share the same geoext tree, so the layers
are<br>
>>> shown/hidden on both maps.<br>
>>><br>
>>> I think I can do it if I start with the overview map example,
here<br>
>>> http://www.openlayers.org/dev/examples/example-list.html<br>
>>><br>
>>> Does someone have a better idea or already tried this?<br>
>>><br>
>>> thanks in advance<br>
>>> Steve<br>
>>><br>
>>> ------------------------------------------------------------------------<br>
>>><br>
>>> _______________________________________________<br>
>>> Users mailing list<br>
>>> Users@openlayers.org<br>
>>> http://openlayers.org/mailman/listinfo/users<br>
>>> <br>
>>> <br>
>> -- <br>
>> Alexandre Dubé<br>
>> Mapgears<br>
>> www.mapgears.com<br>
>><br>
>><br>
>><br>
>><br>
>> <br>
><br>
><br>
> <br>
<br>
<br>
-- <br>
Alexandre Dubé<br>
Mapgears<br>
www.mapgears.com<br>
<br>
_______________________________________________<br>
Users mailing list<br>
Users@openlayers.org<br>
http://openlayers.org/mailman/listinfo/users<br>
</font></tt>
<br>
<br>
<br>