[OpenLayers-Users] Wipe out Map for different projection

Christopher Schmidt crschmidt at metacarta.com
Thu Oct 8 08:30:27 EDT 2009


On Thu, Oct 08, 2009 at 12:58:47PM +0200, Heiko Schröter wrote:
> Hello,
> 
> i'am fairly new to OpenLayer so i don't know if this has been asked before.
> 
> I want to display a map in two projections which can be selected on the webpage.
> EPSG4326 and EPSG900913.
> 
> But i cannot "wipe" out the old projection and reload init(projektion) with the new projection.
> I've tried to do remove the layers etc. But that doesn't work.
> 
> It reloads the new projection but below and outside the <div>map</div>.
> It looks like it is attached to the old (cleaned) <div>map</div>.
> 
> Is there a way to completely "RESET" the OpenLayer.Map setup or is it better to reload the page to completely wipe out the DOM ?

map.destroy();

perhaps?

-- Chris

> Thanks and Regards
> Heiko
> 
> 
> 
> <snip>
> function init(projektion) {
>     registerDataRequester(); // Event Registers i.e. 'layer.events.register'
> 
>     var options = {
> 	projection: new OpenLayers.Projection(projektion),
> 	displayProjection: new OpenLayers.Projection("EPSG:4326"),
> 	units: "m",
> 	maxResolution: 156543.0339,
> 	maxExtent: new OpenLayers.Bounds(xxmin,yymin,xxmax,yymax),
> 	restrcitedExtent: new OpenLayers.Bounds(xxmin,yymin,xxmax,yymax),
> 	controls: [ //new OpenLayers.Control.PanZoom(),
> 		   new OpenLayers.Control.Navigation(),
> 		   new OpenLayers.Control.MousePosition({"numDigits": 2}),
> 		   new OpenLayers.Control.LayerSwitcher()
> 		   ],
> 	numZoomLevels: 8
>     };
> 
>     map = new OpenLayers.Map('map', options);
> 
>     click = new OpenLayers.Control.Click({handlerOptions: {"single": true}});
>     map.addControl(click);
> 
>     var baselayer  = new OpenLayers.Layer.WMS( "IUP WMS", 
>                                                http_mapserver,
>                                                {map: mapfile,
>                                                 layers: "KARTE,GRID,LOGO,COPYRIGHT",
>                                                 transparent: false},
>                                                {singleTile:true, isBaseLayer: true,
>                                                 wrapDateLine: true,
> 						//reproject: true,
>                                                 queryable: true});
>     // "some more Google Layers ... pushing make_base_layers" if EPSG900913
> 
>     make_base_layers.push(baselayer);
> 
>     loadInfoPopUp(baselayer); // 
>     map.addLayers(make_base_layers);
> 
>     map.setCenter(new OpenLayers.LonLat(0, 0), 3);
> <snap>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list