openlayers / ol-cesium

OpenLayers - Cesium integration
http://openlayers.org/ol-cesium/
BSD 2-Clause "Simplified" License
968 stars 321 forks source link

OLCesium destroy function doesn't remove all listeners #1172

Closed mvoermans closed 4 months ago

mvoermans commented 4 months ago

I have an OpenLayers map with a projection that Cesium doesn't support.

map = new Map({
     view: new View({
          projection: 'EPSG:28992'
     })
})

Before init OlCesium I change the View projection

map.setView( 
      new View({
            projection: 'EPSG:3857',
      })
 )

Then I go to 3D and create an OlCesium instance (This works!!)

olCesium = new OLCesium()

But then I go back to 2D and I destroy the OlCesium instance

olCesium.destroy()

Change the projection back to EPSG:28992

map.setView( new View({
        projection: 'EPSG:28992',
 }))

Then I get an javascript error in Cesium

Screenshot 2024-02-27 at 16 50 41

mvoermans commented 4 months ago

Thanks @gberaudo for this quick fix!