[Users] How can I get a reference to a mapPanel.map inside geoext.viewport?

Robert Buckley robertdbuckley at yahoo.com
Sat Apr 2 23:31:15 CEST 2011


Hi,

I am trying to get the reference to the "map" in a geoext viewport in order to 
print the displayed "map" in a new window, but keep getting "undefined" in 
firebug

I have tried document.getElementById('map').innerHTML and also 
Ext.getCmp("map")   as well as this.viewport.mapPanel.map and combinations of 
them all, but the result is always the same.

I´m sure one of you Javascript gurus will find this easy.

my code for the viewport is...

new Ext.Viewport({
        id:"viewport",
        layout: "border",
        items: [{
            region: "center",
            id: "mapPanel",
            xtype: "gx_mappanel",
            map: map,
            layers: [mapnik,layer,vr_wea,ZGB_Grenze],
            zoom:  7,
            split: true
            bbar: [mapLinkButton,
                    {
                        text:"print",
                        icon: '../images/printer.png',
                        handler: function(){
                        
                    Ext.Msg.prompt('Map Title', 'Please enter map title:', 
function(btn, text){
                    if (btn == 'ok'){
                    title = text;
                    var a = window.open('', '', 'width=650px,height=400px');
                    a.document.open("text/html");
                    
a.document.write("<html><body>"+document.getElementById('map').innerHTML + 
"</body></html>");
                    a.document.close();
                    a.print();
                                }
                            });
                                    }
                                    
                
                    }],
            tbar: [toolbarItems, '->', quickzoom],
                    },InfoPanel]
    });


I´d be grateful for any help,

yours,

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110402/25548039/attachment.htm 


More information about the Users mailing list