Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In my application i add layers dynamically. The first added layer is a baseLayer. When i add layer i extend bounds so the new layer could fit map (it works). The problems is that i don't know how to recalculate zoom levels. In my map config i have maxResolution set to auto and the zoomLevel is set to 0. When i add map with bigger extent the zooms are not recalculated, so i cannot see whole layer. I use GeoExt framework with OL. Code:

addLayer:function(record) {

        var layer = _factoryManager.getFactory('layer').getLayer(record, this.getServiceType());

        var map = this.getActiveMap().map;

        map.addLayer(layer);
        console.log('adding layer');
        //console.log(map.getZoomForExtent(map.maxExtent));
        //console.log(map.getZoom());
        map.maxExtent.extend(this.calculateBounds(layer));
        //console.log(map.getZoomForExtent(map.maxExtent));
        //console.log(map.getZoom());
        this.zoomToLayer(layer);
    },

And map creation:

map = Ext.create('OGC.core.panel.MapPanel',{
            map: {
                controls: controls,
                //allOverlays: true, if nothing specified all overlays is set to true
                scope:this,
                projection:this.getCRS(),
                maxExtent:bounds, 
                maxResolution:"auto",
                //allOverlays: false,
                eventListeners:{
                    zoomend:function(evt){
                        console.log(this);
                        console.log('zoomend');
                        console.log(this.getZoom())
                        console.log(this.getScale());
                        Ext.getCmp('map-bottom').update('Scale: ' + this.getScale());
                    }
                }
            },
            layers: [layer]
        });
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.