[OpenLayers-Dev] getDimensions: whether or not it should update the css display attribute

Bruno Binet bruno.binet at camptocamp.com
Thu Jan 14 05:40:02 EST 2010


Hi devs,

I recently came across a bug in OpenLayers that causes Element
getDimensions method to unexpectedly set a display:none on the map
div.
It occured when updateSize was called on the map while map div was
already display:none (from a css class).
The ticket #2414 [1] is reporting the problem.

In my opinion, getDimensions should not set a css attribute to get the
real dimensions of an element. I don't like the idea of a "get" method
to set attributes. If a element is display:none, then getDimensions
should return 0.

When looking at svn history, getDimensions comes from Prototype
framework, and this method is only used in Map.js in getCurrentSize
method, and getCurrentSize is only used in updateSize method and
Layer/MapGuide.js (which I think should use map.size instead).
I'd support the idea of removing the code which temporary make the
element regain its original size, and letting the web application in
charge of manually calling updateSize when display:none is removed
from the map div.
But the current behaviour comes from the beginning of OpenLayers [2],
so there may be good reasons for it?

What is your opinion on that?

Cheers,
Bruno

[1] http://trac.openlayers.org/ticket/2414
[2] http://trac.openlayers.org/changeset/117

-- 
Bruno Binet

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Mail : bruno.binet at camptocamp.com
http://www.camptocamp.com



More information about the Dev mailing list