[OpenLayers-Users] Correct and fast map div resizing

BrainDrain paulborodaev at gmail.com
Fri Sep 12 10:03:24 EDT 2008


powerful community!
I use ExtJS resizable window as a container for my map.
on resize event I have to update map size:
setSize: function(width, height) {
        if (typeof width == "number" && typeof height == "number" &&
(this.map.size.w != width || this.map.size.h != height)) {
            extend(this.map.div.style, { width: width + 'px', height: height
+ 'px' })
            this.map.updateSize();
            extend(this.map, {
                maxResolution: 'auto',
                minResolution: 'auto',
                minScale: null,
                maxScale: null
            });
            this.map.baseLayer.initResolutions();
            this.normalizeToBase(this.map, this.map.baseLayer);
            for (var i = 0; i < this.map.layers.length; i++)
                if (this.map.layers[i] != this.map.baseLayer) {
                this.map.layers[i].initResolutions();
            }
            for (i = 0; i < this.map.layers.length; i++)
                 this.map.layers[i].redraw();

        }
    }

normalizeToBase: function(instance, base) {
        if (!base)
            base = this.map; widget)
        if (typeof instance == 'object' && instance) {
            var keys = ['maxExtent', 'minExtent', 'maxScale', 'minScale',
'maxResolution', 'minResolution', 'units', 'projection']; 
            for (var i = 0; i < keys.length; i++)
                instance[keys[i]] = base[keys[i]];
        }
        return instance;
    },

Without redrawing layers (mapserver tiles with gutter 16) I have strange
tiles overlapping/offsets/artefacts.
But In some cases (when I need to maximize already maximized window to fill
resized window container(at extjs viewport)) redrawing hangs javascript app
execution for a long time. And in some cases redrawing is not required. I
cant figure out in which cases.... or I do something wrong.


-- 
View this message in context: http://www.nabble.com/Correct-and-fast-map-div-resizing-tp19456517p19456517.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list