[OpenLayers-Users] Layerswitcher problem

Alberto Najera anajera at bicimapas.com.mx
Fri Jun 1 10:25:08 PDT 2012


Hello

I am having a problem with the layer switcher while using a Google maps
layer. The layer switcher icon is drawn on the upper left side of the map
window, in the same spot as the zoom controls. Why is this so and how can it
be fixed?  This is the code:


<!DOCTYPE html> 
<html lang='en'> 
<head> 
    <meta charset='utf-8' /> 
    <script type='text/javascript' src="OpenLayers.js"></script>
	<script
src="http://maps.google.com/maps/api/js?sensor=false"></script>	
    <script type='text/javascript'>

    var map;
    
    function init() {
        // Setup our map object
        map = new OpenLayers.Map('map_element', {maxExtent: new
OpenLayers.Bounds( 
-20037508, -20037508, 20037508, 20037508.34
 ) });
        
		// Add a Google Maps Layer
		var google_map_layer = new OpenLayers.Layer.Google(
			'Google Map Layer',
			{"sphericalMercator": true}
		);

     // override default epsg code
			aliasproj = new OpenLayers.Projection("EPSG:3857");
			google_map_layer.projection = aliasproj;

		// Add the layer
		map.addLayer(google_map_layer);
        
    var layer3 = new OpenLayers.Layer.WMS(
		"Ferreterias",
		"http://mysite/cgi-bin/mapserv?", 
		{map: '/home/mysite/tmp/DemoFerre.map', 
		layers:'ferreterias', transparent: true},
{isBaseLayer:false, displayInLayerSwitcher: true});
        
    // Add the layer
		map.addLayer(layer3);   
		
		        
   // Add a layer switcher control
   map.addControl(new OpenLayers.Control.LayerSwitcher({}));
        
        // Zoom the map to the max extent 
		if(!map.getCenter()){
			//map.zoomToMaxExtent();
			map.zoomToExtent(new OpenLayers.Bounds( -11084205,
2011108, -10758597, 2383232))
		}
			
    }

    </script>
	<style type="text/css">
.style1 {
	font-family: Calibri;
	font-size: medium;
}
</style>
</head>

<body onload='init();'>

<span lang="es"><span class="style1"> SECTOR FERRETERO EN
PUEBLA</span></span><div id='map_element' style='width: 500px; height:
500px;'>
		</div>
</body>
</html>

Thanks

Alberto Najera




More information about the Users mailing list