[Users] About a bug in IE: restore a mappanel after removing it from its container

Xudong liuxd8510 at gmail.com
Sat Dec 10 08:54:57 CET 2011


thanks for your help..

but it still doesnt work in IE..

my ultimate goal is to switch mappanel among three different containers,
and I don't want to define three map_panels.. since that will bring down
client performance..
I tried to define three map_panels, but only set one panel's map property
as real map object, the other twos are set as NULL. but for somehow, it
doesnt work well either...

current method (remove, add) works well in FF and Chrome.. just cant walk
around in IE...

On Sat, Dec 10, 2011 at 12:42 AM, Andreas Hocevar <ahocevar at opengeo.org>wrote:

> Your mapPanel variable only holds the configuration of the MapPanel, not
> the component instance.
>
> Add one line of code (see below) and it should work.
>
> Note, however, that hiding a component and showing it again would be less
> expensive than removing and adding it again.
>
> On Dec 10, 2011 7:31 AM, "Xudong" <liuxd8510 at gmail.com> wrote:
> >
> > I am trying to test following scenario:
> >
> >  - A Ext.Window has one gx_mappanel item;
> >
> >
> >  - both Ext.Window and gx_mappanel are stored in variables;
> >
> >
> >
> >
> >  - One button is to remove gx_mappanel item from Ext.Window container;
> >
> >
> >
> >  - The other button is to add this gx_mappanel item back to Ext.Window
> >    container;
> >
> > However:
> >     Once mappanel is removed, it cannot be added back to its container.
> >
> > The issue happens in IE browser, and the error is:
> >
> >     SCRIPT5007: Unable to get value of the property 'removeChild':
> object is null or undefined
> >
> > which is in OpenLayers.js, line 825 character 412:
> >
> >     render: function(div) {
> >         this.div = OpenLayers.Util.getElement(div);
> >         OpenLayers.Element.addClass(this.div, 'olMap');
> >         this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);
> >         this.div.appendChild(this.viewPortDiv);
> >         this.updateSize();
> >     }
> >
> > Codes I've tried:
> >
> >         <! DOCTYPE HTML>
> >     <html>
> >         <head>
> >             <title>GeoExt MapPanel Example</title>
> >
> >         <script type="text/javascript" src="
> http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"></script>
> >         <script type="text/javascript" src="
> http://extjs.cachefly.net/ext-3.2.1/ext-all.js"></script>
> >         <link rel="stylesheet" type="text/css" href="
> http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css" />
> >         <link rel="stylesheet" type="text/css" href="
> http://extjs.cachefly.net/ext-3.2.1/examples/shared/examples.css" />
> >         <script src="http://www.openlayers.org/api/2.10/OpenLayers.js
> "></script>
> >         <script type="text/javascript" src="
> http://api.geoext.org/1.0/script/GeoExt.js"></script>
> >
> >         <script type="text/javascript">
> > var mapPanel;
> > var parentWin;
> >
> > Ext.onReady(function() {
> > var map = new OpenLayers.Map();
> > var layer = new OpenLayers.Layer.WMS(
> > "Global Imagery",
> > "http://maps.opengeo.org/geowebcache/service/wms",
> > {layers: "bluemarble"}
> > );
> > map.addLayer(layer);
> >
> > mapPanel = {
> > xtype : 'gx_mappanel',
> > id : 'MAP_PANEL',
> > map : map,
> > zoom: 6
> > };
> > parentWin = new Ext.Window({
> > title: "GeoExt MapPanel Window",
> > height: 400,
> > width: 600,
> > layout: "fit",
> > items: [mapPanel]
> > }).show();
>
> mapPanel = parentWindow.items.get(0);
>
> > });
> > function mapGone() {
> > parentWin.removeAll();
> > parentWin.doLayout();
> > }
> > function mapBack() {
> > parentWin.add(mapPanel);
> > parentWin.doLayout();
> > }
> > </script>
> >     </head>
> >     <body>
> > <input type="button" onclick="mapGone()" value="map gone"></input>
> > <input type="button" onclick="mapBack()" value="map back"></input>
> >     </body>
> > </html>
> >
> > I really wish somebody can give me some advice...
> > appreciate in advance!!
>
> Andreas.
>
> >
> > _______________________________________________
> > Users mailing list
> > Users at geoext.org
> > http://www.geoext.org/cgi-bin/mailman/listinfo/users
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111210/d55a21b7/attachment.htm 


More information about the Users mailing list