[OpenLayers-Dev] this.events is null error on map.destroy()

cjwhitmore ceri.whitmore at hotmail.co.uk
Fri Dec 19 08:00:33 EST 2008


I've an openlayers (2.7) application where I would like to change the map
projection depending on the zoom level. 
As a test I change from EPSG:900913 to EPSG:4326.

To achieve this I destroy the map and then re-initalise the map adding the
different options.
I have attached an event on the zoomend of the map which is where the
destroy and re-initalise takes place. 

Although it does work I get the error message this.events is null in FFOX
error console. 

I've done a test where I don't destroy the original map, and so the number
of maps grows, but I know longer get the error message. So the error does
seem to come from destroying the map with an event attached to it. I have
tried unregistering the event first but the application still errors.

I add the event using the following:

map1.events.register('zoomend', this, function(){
				testSwap();
			});

and then in testSwap() I remove the event using the following:
map1.events.unregister('zoomend',this, testSwap);


If anyone has tried a similar application and can help, that would be
appreciated.

Cheers

Ceri
-- 
View this message in context: http://www.nabble.com/this.events-is-null-error-on-map.destroy%28%29-tp21089492p21089492.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list