Skip to main content

Posts

Showing posts from November, 2009

OpenLayers - fixing "element is null" error

I've had a hard time trying to debug a problem on a Vector layer that had tooltips as well as regular popups. It worked fine but from time to time Firebug would log an error message like the following: element is null if(!google.gears){google.gears={factory:...setWidth,height:element.offsetHeight};}\n OpenLayers.js (line 228) I'm running OpenLayers 2.8. This error messed up javascript - zooming and panning were broken, the current popup would remain un-close-able, but other markers seemed to work just fine. I managed to track this problem to a null element in Element.js. I'm not sure why the element is null at that point, but it may be a safe thing to do to check if the element exists before trying to change its style... I attached a patch that should solve this (adds an if before setting the style): --- lib/OpenLayers/BaseTypes/Element.js.original 2009-08-04 15:42:45.000000000 +0300 +++ lib/OpenLayers/BaseTypes/Element.js 2009-08-04 15:40:43.000000000 +0300 @@ -4