<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3020" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>&gt; Hi,<BR>&gt; I have to fill the whole viewport 
with the map. I don't mind panning if<BR>&gt; necessary to view the whole map, 
but Iam required not to show any empty area<BR>&gt; around the map. So everytime 
the user increases the viewport size, I need to<BR>&gt; zoom my map 
automatically so that it covers the entire viewport. How can I<BR>&gt; achieve 
this?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>I think your problem 
might be slightly different but I recently found a solution to preventing users 
panning the map&nbsp;until it didn't fill the viewport.&nbsp; I achieved it by 
inheriting from OpenLayers.Map and overloading setCenter:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=427504114-28022007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>DDCVisMap = 
OpenLayers.Class.create();<BR>DDCVisMap.prototype = 
OpenLayers.Class.inherit(OpenLayers.Map, {<BR>&nbsp;&nbsp;&nbsp; setCenter: 
function(center, zoom, dragging) {</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=427504114-28022007>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (center 
== null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
center = this.getCenter();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (zoom == null) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zoom = 
this.getZoom();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>&nbsp;var resolution 
= this.baseLayer.resolutions[zoom];<BR>&nbsp;var size = 
this.getSize();<BR>&nbsp;var w_deg = size.w * resolution;<BR>&nbsp;var h_deg = 
size.h * resolution;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;var 
bounds = new OpenLayers.Bounds(center.lon - w_deg / 
2,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; center.lat - h_deg / 
2,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; center.lon + w_deg / 
2,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; center.lat + h_deg / 
2);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>&nbsp;if 
(bounds.left &lt; -180.0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; center.lon = center.lon 
+ (-180.0 - bounds.left);<BR>&nbsp;}<BR>&nbsp;else if (bounds.right &gt; 180.0) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; center.lon = center.lon - (bounds.right - 
180.0);<BR>&nbsp;}</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>&nbsp;if 
(bounds.bottom &lt; -90.0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; center.lat = center.lat 
+ (-90.0 - bounds.bottom);<BR>&nbsp;}<BR>&nbsp;else if (bounds.top &gt; 90.0) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; center.lat = center.lat - (bounds.top - 
90.0);<BR>&nbsp;}</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=427504114-28022007>&nbsp;OpenLayers.Map.prototype.setCenter.apply(this, 
[center, zoom, dragging]);<BR>&nbsp;&nbsp;&nbsp; }<BR>});</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>I'm an openlayers 
newby so it might not be very idiomatic but provided the maxExtent fills the 
viewport it seems to work.&nbsp; I'm using 
OpenLayers-2.3-rc2.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV align=left><FONT face=Arial size=2>---</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>Stephen Pascoe&nbsp; 01235 
445980</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>British Atmospheric Data 
Centre</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>Rutherford Appleton Laboratory, 
CCLRC</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>