L
L
Leshrac2013-03-06 20:05:53
JavaScript
Leshrac, 2013-03-06 20:05:53

Map in Ext.Window.window is only partially displayed

I create a component based on Ext.Panel.panel that contains a map displayed through openlayers, I put this component in Ext.Window.window.
The map is only partially displayed after loading:
image

Ext.define('MA.view.components.OpenlayersPanel',
    {
        extend: 'Ext.panel.Panel',
        alias: 'widget.openlayerspanel',
        multiSelect: true,
        
        initComponent: function()
        {
            this.callParent(arguments);
            this.on('afterrender', this.afterRender, this);
        },
    
        afterRender: function()
        {
            this.map = new OpenLayers.Map(this.body.dom.id);
            this.layer = new OpenLayers.Layer.OSM('OSM Map');
            this.fromProjection = new OpenLayers.Projection("EPSG:4326");
            this.toProjection = new OpenLayers.Projection("EPSG:900913");
            this.position = new OpenLayers.LonLat(75.1, 61.15).transform(this.fromProjection, this.toProjection);
            this.zoom = 12;
            this.layer.setIsBaseLayer(true);
            this.map.addLayer(this.layer);            
            this.map.setCenter(this.position, this.zoom);
        }
    });


app.js:
Ext.application(
    {
        requires: ['Ext.container.Viewport'],
        name: 'MA',
        appFolder: 'app',
        controllers:
            [
                'Map'
            ],
        launch: function()
        {
            Ext.create('Ext.window.Window',
                {
                    layout:
                    {
                        type: 'vbox'
                    },
                    items:
                        [
                            {
                                xtype: 'openlayerspanel'
                            },
                            {
                                xtype: 'button',
                                text: 'Load',
                            }
                        ]
                }).show();
        }
    });


When the browser window is resized, it starts to display normally ...

Can anyone tell me from which line my hands grow from the wrong place?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
egorinsk, 2013-03-06
@egorinsk

Hands most likely do not grow with you, but with the developers of Ext or OpenLayers, apparently, the card is inserted into the window too early and incorrectly determines its size. Try calling some method to have it recalculate its dimensions.

R
Roman Sopov, 2013-03-07
@sopov

Try setting dimensions in MA.view.components.OpenlayersPanel

U
UZER2006, 2013-04-05
@UZER2006

An alternative to resize is the doLayout() method.
But in general this is not normal. I myself am now struggling with a similar problem, when after loading the page the layout is crooked, and it is corrected only after resizing the window or doLayout ().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question