<br><font size=2 face="sans-serif">solved using clone()</font>
<br><font size=2 face="sans-serif">Thanks Alexandre,</font>
<br><font size=2 face="sans-serif">Steve</font>
<br>
<br><font size=2 face="sans-serif">for(i in overlays)</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif">
var oOriginalLayer = overlays[i];</font>
<br>
<br><font size=2 face="sans-serif">
// add the original layer to the 1st map</font>
<br><font size=2 face="sans-serif">
map.addLayer(oOriginalLayer);
</font>
<br>
<br><font size=2 face="sans-serif">
// create the clone layer, reference it to
its original and add it to the second map</font>
<br><font size=2 face="sans-serif">
var oClonedLayer = oOriginalLayer.clone();</font>
<br><font size=2 face="sans-serif">
oOriginalLayer.cloneLayer = oClonedLayer;</font>
<br><font size=2 face="sans-serif">
ov_map.addLayer(oClonedLayer);</font>
<br>
<br><font size=2 face="sans-serif">
// register the 'visibilitychanged' on the
original layer</font>
<br><font size=2 face="sans-serif">
oOriginalLayer.events.register('visibilitychanged',
oOriginalLayer, function()</font>
<br><font size=2 face="sans-serif">
{</font>
<br><font size=2 face="sans-serif">
//
when this function is called, 'this' is the oOriginal layer</font>
<br><font size=2 face="sans-serif">
//
that had its visibility changed and since it has a reference</font>
<br><font size=2 face="sans-serif">
//
to its clone, we simply use it direclty
</font>
<br><font size=2 face="sans-serif">
this.cloneLayer.setVisibility(this.getVisibility());</font>
<br><font size=2 face="sans-serif">
});</font>
<br><font size=2 face="sans-serif"> }
</font>
<p>
<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></b>
</font>
<p><font size=1 face="sans-serif">05/02/2010 11:40 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, users-bounces@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>
Steve.Toutant@inspq.qc.ca wrote:<br>
><br>
> Alexandre, i don't understand want you mean by<br>
> "and attach it to the original layer ( layer.clonedLayer = <br>
> myCloneLayer )"<br>
> Do you think that could help with the length returned by <br>
> ov_map.getLayersByName(this.name)<br>
The 2nd option is : do not use ov_map.getLayersByName(this.name). <br>
Instead, when creating your myCloneLayer object, make a reference to it
<br>
to its original layer : layer.cloneLayer = myCloneLayer.<br>
<br>
Alexandre<br>
<br>
<br>
> thanks<br>
><br>
> Steve<br>
><br>
><br>
><br>
><br>
> *Alexandre Dube <adube@mapgears.com>@openlayers.org*<br>
> Envoyé par : users-bounces@openlayers.org<br>
><br>
> 05/02/2010 09:43 AM<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>
> 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
( <br>
> 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, <br>
> 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>
> >>> _______________________________________________<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>
><br>
><br>
><br>
<br>
<br>
-- <br>
Alexandre Dubé<br>
Mapgears<br>
www.mapgears.com<br>
<br>
</font></tt>
<br>
<br>
<br>