[OpenLayers-Users] linking layerswitcher and overview map

Janis Elmeris janis.elmeris at intelligentsystems.lv
Mon May 23 04:58:10 EDT 2011


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()].

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.

Janis


On 2011.05.23. 11:16, Sukuchha Shrestha wrote:
> Hello Janis,
> Thanks for your input, but i am having some problems to add layers in my OverviewMap.
> I have three layers:
> var LAY1 = new OpenLayers.Layer.OSM("OpenStreetMap_Mapnik");
> var LAY2 = new OpenLayers.Layer.Google("Google Hybrid",
> 	{type: G_HYBRID_MAP, sphericalMercator: true, numZoomLevels: 20});
> var LAY3 = new OpenLayers.Layer.Google("Google Terrain",
> 	{type: G_PHYSICAL_MAP, sphericalMercator: true, numZoomLevels: 20 });
> 		//map.addLayers([osmarenderLayer, mapnikLayer, ghyb, gter]);
> Now how would i add these layers in OverviewMap.
> 1)I have tried to pass names of the layers ( first parameters of layers constructor as you said);
> var overviewMapControl = new OpenLayers.Control.OverviewMap();
> var options = {layers: [OpenStreetMap_Mapnik,Google Hybrid,Google Terrain]}
> map.addControl(overviewMapControl,options);
> Doing this it returns this;
> px.clone is not a function
> if(px!=null){this.position=px.clone();}
> 2) When i tried to pass layers ID.
> var overviewMapControl = new OpenLayers.Control.OverviewMap();
> var options = {layers: [LAY1,LAY2,LAY3]}
> map.addControl(overviewMapControl,options);
> Doing this it returns this:
> Lay1 is not defined !!
> Please, give me suggestions what is the write way, and why it is not working.
> Have a nive day.
> 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:
> >/  Hello nice people,
> />/
> />/  I want to synchronize the layerswitcher and overview map. I mean when
> />/  i select my layerA in layerswitcher, the overview map should display
> />/  layerA and similarly when i select my layerB in layerswitcher the
> />/  overview map should display layerB.
> />/
> />/  Any idea how to do it !
> />/
> />/  thanks
> />/  sukuchha
> />/
> />
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110523/efb5c8ab/attachment-0001.html


More information about the Users mailing list