[OpenLayers-Users] Disappearing layers

Jerome Freyre jerome.freyre at hispeed.ch
Thu Aug 13 07:40:32 EDT 2009


Hi Eoinyp,

I watched your code. I think you made a mistake with the zoom level on the
function map.setCenter().

Try to modify the line like that:
map.setCenter(new OpenLayers.LonLat(17, 43), 12);

It should work ;)

Here is the copy of your code that I used and modify:
		map = new OpenLayers.Map("map");
		map.addControl(new OpenLayers.Control.LayerSwitcher());
        
		//create layer
		var  velayer = new OpenLayers.Layer.VirtualEarth(
			"Roads Layer",
			{
				'type': VEMapStyle.Road 
			} 
		);
        
		var velayer2 = new OpenLayers.Layer.VirtualEarth(
			"Aerial Layer",
			{
				'type': VEMapStyle.Aerial
			} 
		);

		map.addLayers([velayer, velayer2]);


		map.addControl(new OpenLayers.Control.PanZoomBar());
		map.addControl(new OpenLayers.Control.ScaleLine());
		map.addControl(new OpenLayers.Control.MousePosition());


		map.setCenter(new OpenLayers.LonLat(17, 43), 12);

Sincerly, 
Jérome



eoinyp wrote:
> 
> Im a newbie, having problem with my map layers. Which ever layer I add
> first is visible when the map loads, but when I try to switch layers they
> both disappear. I seem to be missing something fundamental, though I cant
> figure out what!! 
> I am creating the layers and map as follows:
> 
>  init(){
> create layer 1
> create layer 2
> add([layer1,layer2])
> add[map controls]
> }
> 
> The map can be seen at: http://www.eoinmaca.com/maps/OpenLayers/mymap.htm
> 
> Any help greatly appreciated,
> Thanks,
> 
> Eoinyp
> 

-- 
View this message in context: http://n2.nabble.com/Disappearing-layers-tp3436866p3437329.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list