[OpenLayers-Users] Wipe out Map for different projection
Arnd Wippermann
arnd.wippermann at web.de
Thu Oct 8 16:44:23 EDT 2009
Hi Heiko,
This is an example, where you can choose two different projections
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/gc_example.html
<input type="button" value="init Demis" onclick="googleFlag =
false;map.destroy();init();">
And it works.
Also I have an other application
http://gis.ibbeck.de/OLClient/OLClient.asp?KARTE=k10000 with edit controls,
where you can choose different projection. There I use this code to destroy
the old map object:
function destroyKarte()
{
if(map.layers)
for(var i=0;i<map.layers.length;i++)
map.removeLayer(map.layers[i]);
if(map.events)
map.events.remove('click');
if(typeof editControl != 'undefined')
{ try{
editControl.activateControl(editControl.controls[0]);
editControl.controls[1].destroy();
editControl.controls[2].destroy();
editControl.controls[3].destroy();
editControl.controls[4].destroy();
editControl.controls[5].destroy();
editControl.controls[6].destroy();
editControl.controls[7].destroy();
editControl.controls[0].destroy();
editControl.destroy();
}catch(err){};
editControl = null;
}
try{
for(var i=0;i<map.controls.length;i++)
map.controls[i].destroy();
}catch(err){;}
try{
map.destroy();
}catch(err){;}
}
And it works, too.
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Heiko Schröter
Gesendet: Donnerstag, 8. Oktober 2009 15:02
An: Christopher Schmidt
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Wipe out Map for different projection
Am Donnerstag 08 Oktober 2009 14:30:27 schrieben Sie:
> map.destroy();
>
> perhaps?
>
> -- Chris
>
Tried it already and it (seems) not to do the Job cleanly.
It looks that the dependencies/references (click etc) are not
destroyed/removed.
Saying this, tried to remove all the 'register,control' handler as well and
still the 'Layer Switcher, PanZoom etc.' are left over.
The new map instance is than pushed below the olMap.
Regards
Heiko
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list