[OpenLayers-Users] Problems with overlay

Krinke, Claus Claus.Krinke at ML.Niedersachsen.de
Mon Dec 4 04:59:11 EST 2006


Hi List, 
I have a problem defining baselayers and overlays. The layer ROK should be
an overlay. I tried with the param isBaseLayer false, but this dont work.
Where is the problem?

Here ist the code (based on Mumbai Free Map):

<html>
  <head>
    <style type="text/css">
        html,body {
            height: 99%;
            width: 99%;
        }
        #map {
            width: 100%;
            height: 100%;
            border: 1px solid black;
        }
	#notice {
	    right: 1.2em;
	    bottom: 1.2em;
            width: 14em;
	    position: absolute;
	    z-index: 500;
	}
	#noticeText {
            font-size: 1.1em;
	    color: white;
	    font-family: sans-serif;
	    font-weight: bold;
	    background-color: darkblue;
	    padding: .5em;
	    text-align: right;
	}
        #labelText {
            padding: .5em;
	    text-align: center;
        }
	a { 
	    font-size: .6em;
	    color: grey; 
	    text-decoration: none; 
	}
	a:hover { text-decoration: underline; }
    </style>
    <script src="http://openlayers.org/api/2.1-rc3/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
	function getArgs() {
	    var args = new Object();
	    var query = location.search.substring(1);
	    var pairs = query.split("&");           

	    for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');  
		if (pos == -1) continue;         
		var argname = pairs[i].substring(0,pos);  
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);     
	    }
	    return args; 
	}

	var map;
        function init(){
	    var tileSize = new OpenLayers.Size(512,512);
            map = new OpenLayers.Map('map', {
		projection: "EPSG:31467",
		maxExtent:  new OpenLayers.Bounds(3324000, 5675000, 
						  3694000, 5984000),
                maxResolution: (5984000- 5675000) / 512,
                numZoomLevels: 11,
                controls: [],
                units: 'm'
	    });
              var topo = new OpenLayers.Layer.WMS("TOPO",
"http://www.kartenserver.niedersachsen.de/wmsconnector/com.esri.wms.Esrimap/
FFH_Gesamt?", {layers: '6', request: 'getmap'} );
              var rok = new OpenLayers.Layer.WMS( "ROK",
"http://geoportal.geodaten.niedersachsen.de/ml?", {layers:
'fplan_A,bergbau_a,bergbau_l,energie_L', request: 'getmap'},
{'isBaseLayer':false}); 
            map.addLayers([rok, topo]);
            map.addControl(new OpenLayers.Control.MouseToolbar());
            map.addControl(new OpenLayers.Control.PanZoomBar());
            map.addControl(new OpenLayers.Control.LayerSwitcher());

	    var center, zoom, args = getArgs();
	    if (args.x && args.y) {
		center = new OpenLayers.LonLat(parseInt(args.x),
		                               parseInt(args.y));
		zoom = parseInt(args.z);
		if (!zoom) zoom == 0;
	    } else {
		center = new OpenLayers.LonLat(3550000, 5800000);
		zoom = map.getZoomForExtent(map.maxExtent);
	    }
            map.setCenter(center, zoom);
	    map.events.register("moveend", map, updateLinks);
	    updateLinks(); // first time for good measure, bug workaround

	    Rico.Corner.round($('notice'), {
		bgColor: "transparent",
		color: "darkblue",
		blend: false});

        }

	function updateLinks () {
	    var c = map.getCenter();
	    var z = map.getZoom();
	    $('linkLocation').href = "?x=" + Math.round(c.lon)
	                           + "&y=" + Math.round(c.lat)
				   + "&z=" + z;
	    if (false) { // (map.zoom < 5) {
		$('downloadPDF').href = 
		    "javascript:alert('Zoom in before downloading a PDF.')";
	    } else {
		var b = map.getExtent();
		$('downloadPDF').href = "map.pdf?" +
		    "layers=dp+reserved&mapext=" + 
		    [b.left,b.bottom,b.right,b.top].join(" ");
	    }
	}
        // -->
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
    <div id="notice">
        <div id="noticeText">
            <div id="labelText">ROK</div>
            <div><a id="linkLocation" href="">Link to ths location
&rarr;</a></div>
            <div><a id="downloadPDF" href="">Download as PDF
&rarr;</a></div>
            <div><a target="_blank"
href="http://www.crit.org.in/projects/gis">Visit CRIT project page
&rarr;</a></div>
            <div><a target="_blank" href="http://openlayers.org/">Powered by
OpenLayers &rarr;</a></div>
        </div>
    </div> 
  </body>
</html>



Claus Krinke

Niedersächsisches Ministerium
für den ländlichen Raum, Ernährung,
Landwirtschaft und Verbraucherschutz

fon:   0511 120-4715
mail:  claus.krinke at ml.niedersachsen.de



More information about the Users mailing list