<!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>> Hi,<BR>> I have to fill the whole viewport
with the map. I don't mind panning if<BR>> necessary to view the whole map,
but Iam required not to show any empty area<BR>> around the map. So everytime
the user increases the viewport size, I need to<BR>> zoom my map
automatically so that it covers the entire viewport. How can I<BR>> achieve
this?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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 until it didn't fill the viewport. 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> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007>DDCVisMap =
OpenLayers.Class.create();<BR>DDCVisMap.prototype =
OpenLayers.Class.inherit(OpenLayers.Map, {<BR> setCenter:
function(center, zoom, dragging) {</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=427504114-28022007> if (center
== null) {<BR>
center = this.getCenter();<BR>
}
<BR> if (zoom == null)
{<BR> zoom =
this.getZoom();<BR>
}</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007> var resolution
= this.baseLayer.resolutions[zoom];<BR> var size =
this.getSize();<BR> var w_deg = size.w * resolution;<BR> var h_deg =
size.h * resolution;<BR> <BR> var
bounds = new OpenLayers.Bounds(center.lon - w_deg /
2,<BR> center.lat - h_deg /
2,<BR> center.lon + w_deg /
2,<BR> center.lat + h_deg /
2);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007> if
(bounds.left < -180.0) {<BR> center.lon = center.lon
+ (-180.0 - bounds.left);<BR> }<BR> else if (bounds.right > 180.0)
{<BR> center.lon = center.lon - (bounds.right -
180.0);<BR> }</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=427504114-28022007> if
(bounds.bottom < -90.0) {<BR> center.lat = center.lat
+ (-90.0 - bounds.bottom);<BR> }<BR> else if (bounds.top > 90.0)
{<BR> center.lat = center.lat - (bounds.top -
90.0);<BR> }</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=427504114-28022007> OpenLayers.Map.prototype.setCenter.apply(this,
[center, zoom, dragging]);<BR> }<BR>});</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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. I'm using
OpenLayers-2.3-rc2.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2>---</FONT></DIV>
<DIV align=left><FONT face=Arial size=2>Stephen Pascoe 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> </DIV></BODY></HTML>