Hopefully a straightforward question...

I am following the example based on this page here http://www.geoext.org/lib/GeoExt/widgets/MapPanel.html to create a map within a window, here's my code:

new Ext.Window({
    title: "GeoExt MapPanel Window",
    height: 400,
    width: 600,
    layout: "fit",
    items: [{
        xtype: "gx_mappanel",
        id: "mappanel",
        layers: [basemap],
        extent: "-5,35,15,55"

So the above example create a new map in a floating window which is exactly what I'm after... My question is how exactly do I get a handle to the map within this new window so I can add controls and layers after the map has been created? Something along the lines of:

map = grab_the_map_somehow_from_Ext.Window_above();

Thanks for your help.


Define the map as an OL Map separately, then assign it to the mappanel. Works for me.

var map; map = new OpenLayers.Map();


items: [{ xtype: "gx_mappanel", map : map, // <--- add this id: "mappanel", layers: [basemap], extent: "-5,35,15,55" }] ...


@Mapperez solution will manipulate the Ext panel, and OL will not (I think) recognize it as a valid map object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.