<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000099" bgcolor="#ffffff">
    <font size="-1"><font face="Verdana">Well, I'm cloning them. It
        would be your second approach except instead of [LAY1, LAY2,
        LAY3] I would use [LAY1.clone(), LAY2.clone(), LAY3.clone()].<br>
        <br>
        The LAY* variables being undefined must be some issue with your
        particular code, I think. Like, you define them in some scope
        that is not accessible in the place where you're trying to use
        them. If your overview map code immediately follows the map
        creation code, I cannot think of what could be the problem.<br>
        <br>
        Janis<br>
        <br>
        <br>
      </font></font>On 2011.05.23. 11:16, Sukuchha Shrestha wrote:
    <blockquote cite="mid:97638.20333.qm@web29109.mail.ird.yahoo.com"
      type="cite">
      <style type="text/css"><!-- DIV {margin:0px;} --></style>
      <div style="font-family: 'times new roman','new york',times,serif;
        font-size: 12pt;">
        <div>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Hello Janis,</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Thanks for your input, but i am having some problems to add layers in my OverviewMap.</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">I have three layers:</pre>
          <pre>var LAY1 = new OpenLayers.Layer.OSM("OpenStreetMap_Mapnik");
var LAY2 = new OpenLayers.Layer.Google("Google Hybrid",
<span class="Apple-tab-span" style="white-space: pre;">        </span>{type: G_HYBRID_MAP, sphericalMercator: true, numZoomLevels: 20});
var LAY3 = new OpenLayers.Layer.Google("Google Terrain",
<span class="Apple-tab-span" style="white-space: pre;">        </span>{type: G_PHYSICAL_MAP, sphericalMercator: true, numZoomLevels: 20 });
                //map.addLayers([osmarenderLayer, mapnikLayer, ghyb, gter]);</pre>
          <pre>Now how would i add these layers in OverviewMap.</pre>
          <pre>1)I have tried to pass names of the layers ( first parameters of layers constructor as you said);</pre>
          <pre>var overviewMapControl = new OpenLayers.Control.OverviewMap();
var options = {layers: [OpenStreetMap_Mapnik,Google Hybrid,Google Terrain]}</pre>
          <pre>map.addControl(overviewMapControl,options);</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Doing this it returns this; </pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;"><span role="presentation" class="objectBox objectBox-errorMessage hasBreakSwitch "><div role="listitem" class="errorTitle focusRow subLogRow ">px.clone is not a function</div><span class=" "></span><div role="listitem" class="errorSourceBox errorSource-show focusRow subLogRow "><a moz-do-not-send="true" class="errorSource a11yFocus ">if(px!=null){this.position=px.clone();}
</a></div></span></pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">2) When i tried to pass layers ID.</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;"><span class="Apple-style-span" style="white-space: normal;"><pre>var overviewMapControl = new OpenLayers.Control.OverviewMap();
var options = {layers: [LAY1,LAY2,LAY3]}</pre></span><span class="Apple-style-span" style="white-space: normal;"><pre>map.addControl(overviewMapControl,options);</pre><pre><span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Doing this it returns this:</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Lay1 is not defined !!</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Please, give me suggestions what is the write way, and why it is not working.</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">Have a nive day.</pre><pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre></span></pre></span></pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">
</pre>
          <pre style="color: black; font-family: 'Times New Roman'; font-size: medium;">I'm doing it like this:

    map = new OpenLayers.Map (...);
    overviewMapControl = new OpenLayers.Control.OverviewMap (...);

    // Update the base layer of the overview map along with the base
    layer of the main map.
    map.events.register ('changebaselayer', this, function (layer,
    properties)
    {
         if (overviewMapControl.ovmap) {
             overviewMapControl.ovmap.setBaseLayer
    (overviewMapControl.ovmap.getLayersByName (layer.layer.name)[0]);
         }
         // else the overview map is not drawn yet.
    });

You must make sure that you've added to the overview map all the same 
layers you added to the big map, and that they have unique names (the 
first parameter for a layer constructor).

Janis


On 2011.05.19. 18:52, Sukuchha Shrestha wrote:
&gt;<i> Hello nice people,
</i>&gt;<i>
</i>&gt;<i> I want to synchronize the layerswitcher and overview map. I mean when 
</i>&gt;<i> i select my layerA in layerswitcher, the overview map should display 
</i>&gt;<i> layerA and similarly when i select my layerB in layerswitcher the 
</i>&gt;<i> overview map should display layerB.
</i>&gt;<i>
</i>&gt;<i> Any idea how to do it !
</i>&gt;<i>
</i>&gt;<i> thanks
</i>&gt;<i> sukuchha
</i>&gt;<i>
</i>&gt;</pre>
        </div>
      </div>
    </blockquote>
  </body>
</html>