[OpenLayers-Users] Wipe out Map for different projection

Heiko Schröter schroete at iup.physik.uni-bremen.de
Thu Oct 8 06:58:47 EDT 2009


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 ?

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>



More information about the Users mailing list