
Openlayers fluid/fixed layout demo
By: a guest on
Aug 24th, 2010 | syntax:
HTML | size: 1.95 KB | hits: 232 | expires: Never
<OCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> </title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/reset/reset-min.css">
<style>
#container{
height: 100%;
width: 100%;
background: #666;
position: relative;
}
#text{
background: #D66;
}
#map{
position: absolute;
width: 100%;
bottom: 0;
z-index: 2;
}
</style>
</head>
<body>
<div id='container'>
<div id='text'>
<p>Here are a few sentences.</p>
<p>They aren't very large...</p>
<p>Or particularily helpful...</p>
<p>oh well.</p>
</div>
<div id="map">
</div>
</div>
<script src="http://openlayers.org/api/OpenLayers.js" language="javascript" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
var map = null;
var extent = new OpenLayers.Bounds(-180, -90, 180, 90);
function init() {
var options = {
restrictedExtent: extent
}
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?",
{layers: 'basic'}
);
map.addLayers([wms]);
map.setCenter(extent, 1);
}
function toggleRestrictedExtent() {
if(map.restrictedExtent == null) {
map.setOptions({restrictedExtent: extent});
} else {
map.setOptions({restrictedExtent: null});
}
}
function resizeMap(){
$('#map').css('top',$('#text').height()+'px');
}
$(document).ready(function(){
resizeMap();
init();
});
</script>
</body>
</html>