[OpenLayers-Users] changing div size and openlayers size command

Chris Adams chris at genieknows.com
Wed Jun 25 13:56:00 EDT 2008


Correction:

var div = OpenLayers.Util.getElement("map");
div.style.width = width + "px";
div.style.height = height + "px";
map.updateSize();


Chris Adams wrote:
> If you want the map size to change with the window, then you'll need to 
> set at least the height of your body and html tags to 100%. Otherwise, I 
> think you should be able to set pixel values directly to the div in 
> order to resize.
>
> I.e.
>
> html, body {
>  width: 100%;
>  height: 100%;
> }
>
> #map {
>  width: 100%;
>  height: 100%
> }
>
> .
> .
> .
>
> To set your size using JS:
>
> var div = OpenLayers.Util.getElement("map");
> div.style.width = width + "px";
> div.style.height = height + "px";
>
> MilesTogoe wrote:
>   
>> having trouble with OpenLayers in terms of window sizing.  What is the 
>> correct way to specify the relationship between the div and the size 
>> command in OpenLayers, especially when it goes into a div that may 
>> change size according to any changes in the browser window size. 
>> I have tried without much success:
>> #map {
>> width: 100%;
>> height: auto;
>> }
>>
>> function init() {
>> map = new OpenLayers.Map('map');
>> map.Size(100%,100%);
>> layer1 = new OpenLayers.Layer.Image('citymap','/static/maps/citymap.png',
>>
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>   
>>     
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>   




More information about the Users mailing list